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 | 29 | 30 | 31 |
Tags
- 오블완
- GAN
- 백준
- cim
- heapq
- cs공부
- 토이프로젝트
- re_lunchu
- Python
- 알고리즘
- Java
- 현대자동차
- Baekjoon
- 현대
- 티스토리챌린지
- 자바스크립트
- JavaScript
- Algorithm
- boj
- 탐욕법
- 딥러닝
- 소프티어
- 힙큐
- alogorithm
- 자바
- 프로그래머스
- softeer
- programmers
- 스마트팩토리
- 파이썬
Archives
- Today
- Total
eaz_coding
[Baekjoon] 14891 톱니바퀴 본문
문제
https://www.acmicpc.net/problem/14891
풀이
import sys
input = sys.stdin.readline
wheel = [list(input().strip()) for _ in range(4)]
k = int(input())
def check(now, i, directions):
if i == 2:
if now < 3 and wheel[now][i] != wheel[now+1][6]:
directions[now+1] = -directions[now]
directions = check(now+1, i, directions)
elif i == 6:
if now > 0 and wheel[now][i] != wheel[now-1][2]:
directions[now-1] = -directions[now]
directions = check(now-1, i, directions)
return directions
def move(before, direction):
result = before
if direction == 1:
result = [before[7]] + before[:7]
elif direction == -1:
result = before[1:] + [before[0]]
return result
for _ in range(k):
n, d = map(int, input().split())
n -= 1
directions = [0] * 4
directions[n] = d
directions = check(n, 2, directions)
directions = check(n, 6, directions)
for i in range(4):
wheel[i] = move(wheel[i], directions[i])
answer = 0
for i in range(4):
if wheel[i][0] == "1":
answer += 2**i
print(answer)
'eaz_algorithm' 카테고리의 다른 글
[Baekjoon] 1167번 트리의 지름 (0) | 2024.11.21 |
---|---|
[Baekjoon]9019번 DSLR (0) | 2024.11.20 |
[Baekjoon] 1300 K번째 수 (0) | 2024.11.16 |
[Baekjoon] 1904번 01타일 (0) | 2024.11.15 |
[Baekjoon] 2805 나무 자르기 (1) | 2024.11.14 |