結果
問題 | No.1420 国勢調査 (Easy) |
ユーザー | persimmon-persimmon |
提出日時 | 2021-03-15 10:08:12 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,202 bytes |
コンパイル時間 | 197 ms |
コンパイル使用メモリ | 82,304 KB |
実行使用メモリ | 129,516 KB |
最終ジャッジ日時 | 2024-04-24 14:45:07 |
合計ジャッジ時間 | 10,728 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | WA | - |
testcase_01 | AC | 41 ms
52,608 KB |
testcase_02 | WA | - |
testcase_03 | WA | - |
testcase_04 | WA | - |
testcase_05 | WA | - |
testcase_06 | WA | - |
testcase_07 | AC | 244 ms
106,952 KB |
testcase_08 | AC | 210 ms
99,184 KB |
testcase_09 | AC | 215 ms
107,020 KB |
testcase_10 | AC | 237 ms
107,280 KB |
testcase_11 | AC | 226 ms
107,276 KB |
testcase_12 | AC | 96 ms
97,536 KB |
testcase_13 | WA | - |
testcase_14 | AC | 96 ms
97,664 KB |
testcase_15 | WA | - |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | WA | - |
testcase_20 | WA | - |
testcase_21 | WA | - |
testcase_22 | WA | - |
testcase_23 | WA | - |
testcase_24 | WA | - |
testcase_25 | WA | - |
testcase_26 | WA | - |
testcase_27 | AC | 207 ms
115,748 KB |
testcase_28 | AC | 212 ms
115,564 KB |
testcase_29 | AC | 206 ms
115,820 KB |
testcase_30 | AC | 216 ms
115,688 KB |
testcase_31 | AC | 220 ms
116,200 KB |
ソースコード
import sys input=sys.stdin.readline def main1(n,m,aby): g=[[] for _ in range(n)] for a,b,y in aby: a,b=a-1,b-1 g[a].append([b,y]) g[b].append([a,y]) x=[0]*n flg=True for i in range(30): mi=set(range(n)) seen=[-1]*n while mi: v0=mi.pop() for d in (0,1): flg=True seen[v0]=d todo=[[v0,-1]] while todo: v,p=todo.pop() mi.discard(v) for nv,y in g[v]: if nv==p:continue if seen[nv]==-1: seen[nv]=seen[v]^((y>>i)&1) todo.append([nv,v]) elif seen[nv]==seen[v]^((y>>i)&1): continue else: flg=False break if not flg:break if not flg:return [-1] bit=1<<i for v in range(n): if seen[v]>0: x[v]+=bit return x def chk(n,aby,x): for a,b,y in aby: a,b=a-1,b-1 if x[a]^x[b]==y: pass else: return False return True if __name__=='__main__': n,m=map(int,input().split()) aby=[] for _ in range(m): a,b=map(int,input().split()) y=int(input()) aby.append([a,b,y]) ret1=main1(n,m,aby) print(*ret1,sep='\n')