結果
問題 | No.2042 RGB Caps |
ユーザー | tamato |
提出日時 | 2022-08-19 21:34:44 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,386 bytes |
コンパイル時間 | 339 ms |
コンパイル使用メモリ | 82,464 KB |
実行使用メモリ | 81,216 KB |
最終ジャッジ日時 | 2024-10-08 07:44:49 |
合計ジャッジ時間 | 4,510 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 37 ms
52,756 KB |
testcase_01 | WA | - |
testcase_02 | AC | 37 ms
52,772 KB |
testcase_03 | AC | 37 ms
53,468 KB |
testcase_04 | AC | 39 ms
53,412 KB |
testcase_05 | AC | 37 ms
52,856 KB |
testcase_06 | AC | 50 ms
69,184 KB |
testcase_07 | WA | - |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | WA | - |
testcase_13 | WA | - |
testcase_14 | WA | - |
testcase_15 | WA | - |
testcase_16 | WA | - |
testcase_17 | WA | - |
ソースコード
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 # 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()