結果
| 問題 | No.3426 Mod K Graph Increments (Hard) |
| コンテスト | |
| ユーザー |
titia
|
| 提出日時 | 2026-01-18 03:06:44 |
| 言語 | PyPy3 (7.3.17) |
| 結果 |
AC
|
| 実行時間 | 293 ms / 2,000 ms |
| コード長 | 977 bytes |
| 記録 | |
| コンパイル時間 | 352 ms |
| コンパイル使用メモリ | 82,668 KB |
| 実行使用メモリ | 131,236 KB |
| 最終ジャッジ日時 | 2026-01-18 03:06:47 |
| 合計ジャッジ時間 | 2,212 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge6 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 10 |
ソースコード
import sys
input = sys.stdin.readline
T=int(input())
for tests in range(T):
N,M,K=map(int,input().split())
E=[[] for i in range(N)]
for i in range(M):
x,y=map(int,input().split())
x-=1
y-=1
E[x].append(y)
E[y].append(x)
B=list(map(int,input().split()))
D=[-1]*N
flag=1
D[0]=0
Q=[0]
while Q:
x=Q.pop()
for to in E[x]:
if D[to]==-1:
D[to]=D[x]^1
Q.append(to)
else:
if D[to]==D[x]:
flag=0
break
if flag==0:
SUM=sum(B)%K
if K%2==0:
if SUM%2==1:
print("No")
else:
print("Yes")
else:
print("Yes")
continue
score=[0,0]
for i in range(N):
score[D[i]]+=B[i]
if score[0]%K==score[1]%K:
print("Yes")
else:
print("No")
titia