結果

問題 No.3426 Mod K Graph Increments (Hard)
コンテスト
ユーザー titia
提出日時 2026-01-18 03:01:26
言語 PyPy3
(7.3.17)
結果
WA  
実行時間 -
コード長 818 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 327 ms
コンパイル使用メモリ 82,924 KB
実行使用メモリ 131,188 KB
最終ジャッジ日時 2026-01-18 03:01:29
合計ジャッジ時間 2,405 ms
ジャッジサーバーID
(参考情報)
judge6 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 3 WA * 7
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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:
        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")
    
    
0