結果
| 問題 |
No.2948 move move rotti
|
| コンテスト | |
| ユーザー |
titia
|
| 提出日時 | 2024-10-25 22:42:06 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 880 bytes |
| コンパイル時間 | 372 ms |
| コンパイル使用メモリ | 82,500 KB |
| 実行使用メモリ | 84,292 KB |
| 最終ジャッジ日時 | 2024-10-25 22:42:13 |
| 合計ジャッジ時間 | 6,043 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | TLE * 1 -- * 27 |
ソースコード
import sys
input = sys.stdin.readline
N,M,K=map(int,input().split())
X=list(map(int,input().split()))
for i in range(K):
X[i]-=1
E=[[] for i in range(N)]
for i in range(M):
u,v=map(int,input().split())
u-=1
v-=1
E[u].append(v)
E[v].append(u)
def calc(x):
LIST=[set() for i in range(N)]
LIST[0].add(x)
Q=[(x,1<<x,0)]
USE=set((x,1<<x,0))
while Q:
now,hist,kai=Q.pop()
for to in E[now]:
if hist & (1<<to) == 0:
hist2=hist|(1<<to)
LIST[kai+1].add(to)
necq=(to,hist2,kai+1)
USE.add(necq)
Q.append(necq)
return LIST
LIST=[set(range(N)) for i in range(N)]
for x in X:
L=calc(x)
for i in range(N):
LIST[i]&=L[i]
for i in range(N):
if len(LIST[i])>0:
print("Yes")
exit()
print("No")
titia