結果
| 問題 |
No.2948 move move rotti
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-10-25 22:43:00 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 882 bytes |
| コンパイル時間 | 430 ms |
| コンパイル使用メモリ | 82,540 KB |
| 実行使用メモリ | 97,028 KB |
| 最終ジャッジ日時 | 2024-10-25 22:43:05 |
| 合計ジャッジ時間 | 3,944 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 23 WA * 5 |
ソースコード
from collections import deque
N,M,K=list(map(int,input().split()))
X=list(map(int,input().split()))
#print(X)
if len(set(X))==1:
print("Yes")
exit()
path=[]
for i in range(N):
path.append([])
for j in range(M):
u,v=list(map(int,input().split()))
u-=1
v-=1
path[u].append(v)
path[v].append(u)
for i in range(K):
X[i]-=1
for i in range(N):
if i in X:
#print(i,X)
continue
Q=deque()
check=set()
Q.append((2**i,i,0))
check.add((2**i,i))
cnt=[]
for j in range(N):
cnt.append(set())
while len(Q)>0:
c,p,d=Q.popleft()
#print(c,p,d)
for j in path[i]:
if c&2**j==0 and (c|2**j,j) not in check:
check.add((c|2**j,j))
Q.append((c|2**j,j,d+1))
cnt[j].add(d+1)
g=set()
for j in range(N):
g.add(j)
for j in X:
g=g&cnt[j]
#print(i,g,cnt)
if len(g)!=0:
print("Yes")
exit()
print("No")