結果
問題 | No.2042 RGB Caps |
ユーザー |
![]() |
提出日時 | 2022-08-19 21:40:32 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,784 bytes |
コンパイル時間 | 188 ms |
コンパイル使用メモリ | 82,036 KB |
実行使用メモリ | 81,456 KB |
最終ジャッジ日時 | 2024-10-08 07:56:44 |
合計ジャッジ時間 | 4,870 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 WA * 1 |
other | AC * 3 WA * 13 |
ソースコード
mod = 998244353 def main(): import sys input = sys.stdin.readline T = {"R": 0, "G": 1, "B": 2} N, K = map(int, input().split()) ans = [""] * (N + 10) for _ in range(K): a, c = input().split() a = int(a) ans[a-1] = c for i in range((N // 3) + 1): cnt = [0] * 3 for j in range(3): s = ans[i * 3 + j] if s == "R": cnt[0] += 1 elif s == "G": cnt[1] += 1 elif s == "B": cnt[2] += 1 # j = 0 if ans[i * 3] == "": if cnt[0] == 0: ans[i * 3] = "R" cnt[0] += 1 elif cnt[1] == 0: ans[i * 3] = "G" cnt[1] += 1 else: ans[i * 3] = "B" cnt[2] += 1 else: s = ans[i * 3] if cnt[T[s]] > 1: cnt[T[s]] -= 1 if cnt[0] == 0: ans[i * 3] = "R" cnt[0] += 1 elif cnt[1] == 0: ans[i * 3] = "G" cnt[1] += 1 else: ans[i * 3] = "B" cnt[2] += 1 # j = 1 if ans[i * 3 + 1] == "": if cnt[0] == 0: ans[i * 3 + 1] = "R" cnt[0] += 1 elif cnt[1] == 0: ans[i * 3 + 1] = "G" cnt[1] += 1 else: ans[i * 3 + 1] = "B" cnt[2] += 1 else: s = ans[i * 3 + 1] if cnt[T[s]] > 1: cnt[T[s]] -= 1 if cnt[0] == 0: ans[i * 3 + 1] = "R" cnt[0] += 1 elif cnt[1] == 0: ans[i * 3 + 1] = "G" cnt[1] += 1 else: ans[i * 3 + 1] = "B" cnt[2] += 1 # j = 2 if ans[i * 3 + 2] == "": if cnt[0] == 0: ans[i * 3 + 2] = "R" cnt[0] += 1 elif cnt[1] == 0: ans[i * 3 + 2] = "G" cnt[1] += 1 else: ans[i * 3 + 2] = "B" cnt[2] += 1 else: s = ans[i * 3 + 2] if cnt[T[s]] > 1: cnt[T[s]] -= 1 if cnt[0] == 0: ans[i * 3 + 2] = "R" cnt[0] += 1 elif cnt[1] == 0: ans[i * 3 + 2] = "G" cnt[1] += 1 else: ans[i * 3 + 2] = "B" cnt[2] += 1 print("".join(ans[:N])) if __name__ == '__main__': main()