ps | |
---|---|
링크 | acmicpc.net/… |
출처 | BOJ |
문제 번호 | 32381 |
문제명 | Coloring 2: Electric Boogaloo |
레벨 | 골드 2 |
분류 |
애드 혹 |
시간복잡도 | O(n) |
인풋사이즈 | n<=300,000 |
사용한 언어 | Python 3.11 |
제출기록 | 70976KB / 252ms |
최고기록 | 252ms |
해결날짜 | 2024/10/15 |
"""Solution code for "BOJ 32381. Coloring 2: Electric Boogaloo".
- Problem link: https://www.acmicpc.net/problem/32381
- Solution link: http://www.teferi.net/ps/problems/boj/32381
"""
def main():
N, Q = [int(x) for x in input().split()] # pylint: disable=unused-variable
black_counts = [int(x) for x in input().split()]
flipped_col_count = flipped_row_count = 0
black_count_cur = 0
answer = []
for b in black_counts:
black_count_prev, black_count_cur = black_count_cur, b
inc = black_count_cur - black_count_prev
if inc == N - (flipped_col_count * 2) and flipped_row_count < N:
answer.append(f'R {flipped_row_count + 1}')
flipped_row_count += 1
elif inc == -(N - (flipped_col_count * 2)) and flipped_row_count > 0:
answer.append(f'R {flipped_row_count}')
flipped_row_count -= 1
elif inc == N - (flipped_row_count * 2) and flipped_col_count < N:
answer.append(f'C {flipped_col_count + 1}')
flipped_col_count += 1
elif inc == -(N - (flipped_row_count * 2)) and flipped_col_count > 0:
answer.append(f'C {flipped_col_count}')
flipped_col_count -= 1
else:
print('-1')
break
else:
print('\n'.join(answer))
if __name__ == '__main__':
main()