結果
問題 | No.1421 国勢調査 (Hard) |
ユーザー | chineristAC |
提出日時 | 2021-03-05 23:04:34 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,784 bytes |
コンパイル時間 | 182 ms |
コンパイル使用メモリ | 82,304 KB |
実行使用メモリ | 81,408 KB |
最終ジャッジ日時 | 2024-10-07 04:32:22 |
合計ジャッジ時間 | 6,880 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 49 ms
56,576 KB |
testcase_01 | AC | 47 ms
55,936 KB |
testcase_02 | WA | - |
testcase_03 | AC | 70 ms
70,528 KB |
testcase_04 | AC | 75 ms
70,528 KB |
testcase_05 | WA | - |
testcase_06 | AC | 69 ms
70,656 KB |
testcase_07 | WA | - |
testcase_08 | AC | 70 ms
70,912 KB |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | AC | 49 ms
56,064 KB |
testcase_13 | AC | 48 ms
56,064 KB |
testcase_14 | AC | 50 ms
56,320 KB |
testcase_15 | AC | 49 ms
56,448 KB |
testcase_16 | WA | - |
testcase_17 | AC | 65 ms
68,352 KB |
testcase_18 | WA | - |
testcase_19 | AC | 49 ms
56,832 KB |
testcase_20 | AC | 49 ms
56,320 KB |
testcase_21 | AC | 67 ms
68,480 KB |
testcase_22 | AC | 433 ms
81,152 KB |
testcase_23 | AC | 453 ms
81,024 KB |
testcase_24 | AC | 441 ms
79,616 KB |
testcase_25 | AC | 447 ms
81,408 KB |
testcase_26 | AC | 439 ms
79,744 KB |
testcase_27 | AC | 118 ms
78,336 KB |
testcase_28 | AC | 162 ms
78,336 KB |
testcase_29 | AC | 135 ms
78,592 KB |
testcase_30 | AC | 102 ms
78,080 KB |
testcase_31 | AC | 121 ms
78,336 KB |
ソースコード
import sys,random,bisect from collections import deque,defaultdict from heapq import heapify,heappop,heappush from itertools import permutations from math import log,gcd input = lambda :sys.stdin.readline().rstrip() mi = lambda :map(int,input().split()) li = lambda :list(mi()) N,M = mi() vec = [] for i in range(M): A = int(input()) B = li() y = int(input()) c = 0 for b in B: c += 1<<(b-1) vec.append((c,y)) def solve(bit): bit_vec = [] for i in range(M): c,y = vec[i] d = 2*c + (y>>bit & 1) bit_vec.append((c,d)) base_c = [] base_d = [] for c,d in bit_vec: f_c,f_d = False,False for b in base_c: c = min(c,c^b) if c: f_c = True base_c.append(c) for b in base_d: d = min(d,d^b) if d: f_d = True base_d.append(d) if f_d: if not f_c: return -1 base_d.sort() assert 1 not in base_d pos = 0 res = [0 for i in range(N)] for d in base_d: n = d.bit_length() assert pos < n-1 tmp = d & 1 for i in range(pos): tmp ^= (d>>(i+1)) & res[i] #print(pos,n,tmp,res) for i in range(pos,n-1): if tmp: res[i] = 1 tmp = 0 else: res[i] = 0 pos = n-1 assert pos == N return res ans = [0 for i in range(N)] for bit in range(30): tmp = solve(bit) if tmp == - 1: exit(print(-1)) else: for i in range(N): ans[i] += tmp[i]<<bit print(*ans,sep="\n") for c,y in vec: tmp = 0 for i in range(N): if c>>i & 1: tmp ^= ans[i] #assert y==tmp