結果
問題 |
No.3234 Infinite Propagation
|
ユーザー |
|
提出日時 | 2025-08-15 22:10:48 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 214 ms / 2,000 ms |
コード長 | 723 bytes |
コンパイル時間 | 248 ms |
コンパイル使用メモリ | 82,648 KB |
実行使用メモリ | 88,868 KB |
最終ジャッジ日時 | 2025-08-15 22:11:08 |
合計ジャッジ時間 | 2,925 ms |
ジャッジサーバーID (参考情報) |
judge6 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 18 |
ソースコード
from collections import deque T=int(input()) for _ in range(T): N=int(input()) X=[] Xs=set() Y=[] for _ in range(N): x,y=input().split() X.append(x) Y.append(y) done=0 Q=deque([("a",[])]) while Q: s,conv=Q.popleft() for i,x in enumerate(X): if x in s: for j in range(len(s)-len(x)+1): if x==s[j:j+len(x)]: if i not in conv: Q.append((s[:j]+Y[i]+s[j+len(x):],conv+[i])) else: done=1 if done:break if done:break if done:break print("Yes" if done else "No")