Notice
Recent Posts
Recent Comments
Link
| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 1 | 2 | 3 | 4 | 5 | 6 | 7 |
| 8 | 9 | 10 | 11 | 12 | 13 | 14 |
| 15 | 16 | 17 | 18 | 19 | 20 | 21 |
| 22 | 23 | 24 | 25 | 26 | 27 | 28 |
Tags
- LAN의 분류
- r-value참조자
- 값/참조/주소에 의한 전달
- 논리 연산
- 운영체제 기능
- C언어 계산기 프로그램
- 문자형 배열
- C언어 덱
- 주기억장치
- const화
- 회전 및 자리 이동 연산
- 프로그래머스 배열만들기4
- 백준 파이썬
- C언어 스택 연산
- 네트워크 결합
- 프로그래머스 푸드 파이트 대회
- 유형 변환
- IPv4 주소체계
- 괄호 검사 프로그램
- c언어 괄호검사
- 원형 연결 구조 연결된 큐
- 범위 기반 for문
- const l-value참조자
- getline()함수
- string유형
- 입출력 관리자
- l-value참조자
- auto 키워드
- 알고리즘 조건
- 문제해결 단계
Archives
- Today
- Total
chyam
[백준] 1063번, python - 킹 본문

https://www.acmicpc.net/problem/1063
dic = {
"R": (1,0),
"L": (-1,0),
"B": (0,1),
"T": (0,-1),
"RT": (1,-1),
"LT": (-1,-1),
"RB": (1,1),
"LB": (-1,1)
}
king, stone, n = input().split()
king_x, king_y = ord(king[0])-65 , 8 - int(king[1])
stone_x, stone_y = ord(stone[0])-65 , 8 - int(stone[1])
for _ in range(int(n)):
move = input()
dx, dy = dic[move]
nx, ny = king_x + dx, king_y + dy
if 0 <= nx < 8 and 0 <= ny < 8: # 킹이 먼저 이동 가능해야 함
if nx == stone_x and ny == stone_y: # 돌과 충돌
sx, sy = stone_x + dx, stone_y + dy
if 0 <= sx < 8 and 0 <= sy < 8: # 돌도 이동 가능
king_x, king_y = nx, ny
stone_x, stone_y = sx, sy
else:
king_x, king_y = nx, ny
print(chr(king_x+65) + str(8-king_y))
print(chr(stone_x+65) + str(8-stone_y))'백준' 카테고리의 다른 글
| [백준] 1713번, python - 후보 추천하기 (0) | 2025.08.22 |
|---|---|
| [백준] 1347번,python - 미로 만들기 (0) | 2025.08.19 |
| [백준] 1417번,python - 국회의원 선거 (2) | 2025.08.14 |
| [백준] 2578번,python - 빙고 (1) | 2025.08.13 |
| [백준] 1966번,python - 프린터 큐 (4) | 2025.08.10 |
