結果
| 問題 |
No.3323 岩井星式ジャンケン
|
| コンテスト | |
| ユーザー |
titia
|
| 提出日時 | 2025-11-02 01:19:58 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 70 ms / 2,000 ms |
| コード長 | 820 bytes |
| コンパイル時間 | 368 ms |
| コンパイル使用メモリ | 82,620 KB |
| 実行使用メモリ | 81,684 KB |
| 最終ジャッジ日時 | 2025-11-02 01:20:02 |
| 合計ジャッジ時間 | 3,625 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 26 |
ソースコード
import sys
input = sys.stdin.readline
N,M=map(int,input().split())
S=[input().strip() for i in range(N)]
X=dict()
X["P"]="C"
X["G"]="P"
X["C"]="G"
L=list(range(N))
Q=[([],L,0)]
while Q:
Q.sort(key=lambda x:len(x[1]),reverse=True)
#print(Q)
now,L,ind=Q.pop()
if L==[]:
while len(now)<M:
now.append("G")
print("".join(now))
exit()
if ind==M:
if L==[]:
print("".join(now))
exit()
else:
continue
for x in "PGC":
flag=1
LL=[]
for i in L:
if S[i][ind]==X[x]:
flag=0
break
if S[i][ind]==x:
LL.append(i)
if flag==1:
Q.append((now+[x],LL,ind+1))
print(-1)
titia