結果
| 問題 | No.3323 岩井星式ジャンケン |
| コンテスト | |
| ユーザー |
👑 |
| 提出日時 | 2026-09-04 22:05:21 |
| 言語 | PyPy3 (7.3.23 + ACL) |
| 結果 |
AC
不安定
|
| 実行時間 | 143 ms / 2,000 ms |
| + 94µs | |
| コード長 | 912 bytes |
| 記録 | |
| コンパイル時間 | 273 ms |
| コンパイル使用メモリ | 95,692 KB |
| 実行使用メモリ | 113,692 KB |
| 最終ジャッジ日時 | 2026-09-04 22:05:55 |
| 合計ジャッジ時間 | 5,138 ms |
|
ジャッジサーバーID (参考情報) |
judge2_0 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 26 |
ソースコード
def win(hands):
if len(hands) == 1:
h = hands.pop()
if h == "G":
return "P"
elif h == "C":
return "G"
else:
return "C"
else:
l, r = sorted(hands)
if (l, r) == ("C", "G"):
return "G"
elif (l, r) == ("C", "P"):
return "C"
else:
return "P"
N, M = [int(s) for s in input().split()]
S = [[*input()] for _ in range(N)]
remain = {*range(N)}
answers = []
for m in range(M):
hands = {S[r][m] for r in remain}
if len(hands) == 3:
print("-1")
exit()
if len(hands) == 0:
answers.append("G")
continue
w = win(hands)
answers.append(w)
nremain = set()
for r in remain:
if S[r][m] == w:
nremain.add(r)
remain = nremain
if len(remain) == 0:
print(*answers, sep="")
else:
print(-1)