結果
問題 | No.1421 国勢調査 (Hard) |
ユーザー | chineristAC |
提出日時 | 2021-03-05 23:05:25 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 448 ms / 2,000 ms |
コード長 | 1,801 bytes |
コンパイル時間 | 240 ms |
コンパイル使用メモリ | 82,204 KB |
実行使用メモリ | 81,408 KB |
最終ジャッジ日時 | 2024-10-07 04:33:41 |
合計ジャッジ時間 | 5,765 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 52 ms
56,064 KB |
testcase_01 | AC | 46 ms
55,936 KB |
testcase_02 | AC | 67 ms
70,528 KB |
testcase_03 | AC | 68 ms
70,400 KB |
testcase_04 | AC | 72 ms
70,656 KB |
testcase_05 | AC | 66 ms
70,400 KB |
testcase_06 | AC | 67 ms
70,400 KB |
testcase_07 | AC | 67 ms
70,528 KB |
testcase_08 | AC | 67 ms
70,400 KB |
testcase_09 | AC | 69 ms
71,680 KB |
testcase_10 | AC | 69 ms
70,528 KB |
testcase_11 | AC | 70 ms
71,040 KB |
testcase_12 | AC | 47 ms
56,064 KB |
testcase_13 | AC | 46 ms
56,448 KB |
testcase_14 | AC | 47 ms
56,192 KB |
testcase_15 | AC | 47 ms
56,192 KB |
testcase_16 | AC | 63 ms
68,736 KB |
testcase_17 | AC | 62 ms
68,352 KB |
testcase_18 | AC | 64 ms
68,608 KB |
testcase_19 | AC | 47 ms
56,320 KB |
testcase_20 | AC | 46 ms
56,704 KB |
testcase_21 | AC | 63 ms
68,608 KB |
testcase_22 | AC | 429 ms
81,256 KB |
testcase_23 | AC | 443 ms
81,024 KB |
testcase_24 | AC | 425 ms
79,616 KB |
testcase_25 | AC | 448 ms
81,408 KB |
testcase_26 | AC | 436 ms
79,824 KB |
testcase_27 | AC | 105 ms
78,372 KB |
testcase_28 | AC | 157 ms
78,592 KB |
testcase_29 | AC | 123 ms
78,336 KB |
testcase_30 | AC | 98 ms
77,696 KB |
testcase_31 | AC | 119 ms
78,660 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 and d>>(i+1) & 1: 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