結果

問題 No.3323 岩井星式ジャンケン
コンテスト
ユーザー i_taku
提出日時 2026-01-20 09:29:52
言語 PyPy3
(7.3.17)
結果
WA  
実行時間 -
コード長 607 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 333 ms
コンパイル使用メモリ 82,784 KB
実行使用メモリ 87,764 KB
最終ジャッジ日時 2026-01-20 09:29:57
合計ジャッジ時間 4,562 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1 WA * 2
other AC * 6 WA * 20
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

N, M = map(int, input().split())
S = [input() for _ in range(N)]
fin = set()
H = "GCPG"

def next_h(c):
    return H[H.index(c) + 1]

ans = []
for k in range(M):
    hand = {'G', 'C', 'P'}
    for i in range(N):
        if i in fin:
            continue
        hand.discard(next_h(S[i][k]))
    match len(hand):
        case 0:
            print(-1)
            exit()
        case 1:
            res = hand.pop()
        case 2:
            res = [h for h in H if h not in hand].pop()
    for i in range(N):
        if S[i][k] == next_h(res):
            fin.add(i)
    ans.append(res)
print(*ans, sep='')
0