結果
| 問題 | No.3425 Mod K Graph Increments (Easy) |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-10-28 08:19:51 |
| 言語 | PyPy3 (8.0.1 + ACL) |
| 結果 |
RE
不安定
|
| 実行時間 | - |
| コード長 | 792 bytes |
| 記録 | |
| コンパイル時間 | 338 ms |
| コンパイル使用メモリ | 64,512 KB |
| 実行使用メモリ | 94,388 KB |
| 最終ジャッジ日時 | 2026-10-28 08:19:57 |
| 合計ジャッジ時間 | 4,750 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge7_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 7 RE * 1 |
ソースコード
from collections import deque
def dfs(i,j):
Pa[i] = j
if i!=1 and len(G[i])==1:
Leaf.append(i)
return
for k in G[i]:
if k==j:continue
dfs(k,i)
T = int(input())
for _ in range(T):
N,M,K = map(int,input().split())
G = {i:[] for i in range(1,N+1)}
for _ in range(M):
u,v = map(int,input().split())
G[u].append(v)
G[v].append(u)
Pa = [0]*(N+1)
Leaf = deque([])
dfs(1,0)
B = [0]+list(map(int,input().split()))
Deg = [0]+[len(G[u])-1 for u in range(1,N+1)]
Deg[1] += 1
while Leaf:
u = Leaf.popleft()
v = Pa[u]
B[v] = (B[v]-B[u])%K
Deg[v] -= 1
if Deg[v]==0:
Leaf.append(v)
if B[1]==0:
print("Yes")
else:
print("No")