結果

問題 No.3323 岩井星式ジャンケン
コンテスト
ユーザー titia
提出日時 2025-11-02 01:14:44
言語 PyPy3
(7.3.15)
結果
MLE  
実行時間 -
コード長 646 bytes
コンパイル時間 2,695 ms
コンパイル使用メモリ 82,504 KB
実行使用メモリ 823,484 KB
最終ジャッジ日時 2025-11-02 01:14:53
合計ジャッジ時間 5,276 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 2 MLE * 1 -- * 23
権限があれば一括ダウンロードができます

ソースコード

diff #

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:
    now,L,ind=Q.pop()

    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)

    

    
0