結果
問題 | No.1421 国勢調査 (Hard) |
ユーザー | chineristAC |
提出日時 | 2021-03-05 22:54:41 |
言語 | PyPy3 (7.3.15) |
結果 |
RE
|
実行時間 | - |
コード長 | 1,749 bytes |
コンパイル時間 | 266 ms |
コンパイル使用メモリ | 82,264 KB |
実行使用メモリ | 81,536 KB |
最終ジャッジ日時 | 2024-10-07 04:11:32 |
合計ジャッジ時間 | 7,628 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 41 ms
56,836 KB |
testcase_01 | AC | 42 ms
56,816 KB |
testcase_02 | RE | - |
testcase_03 | AC | 62 ms
72,056 KB |
testcase_04 | AC | 63 ms
71,880 KB |
testcase_05 | RE | - |
testcase_06 | AC | 63 ms
71,084 KB |
testcase_07 | RE | - |
testcase_08 | AC | 61 ms
70,928 KB |
testcase_09 | RE | - |
testcase_10 | RE | - |
testcase_11 | RE | - |
testcase_12 | AC | 43 ms
56,624 KB |
testcase_13 | AC | 42 ms
56,536 KB |
testcase_14 | AC | 43 ms
56,824 KB |
testcase_15 | AC | 41 ms
56,756 KB |
testcase_16 | RE | - |
testcase_17 | AC | 64 ms
69,444 KB |
testcase_18 | RE | - |
testcase_19 | AC | 43 ms
56,928 KB |
testcase_20 | AC | 42 ms
58,000 KB |
testcase_21 | AC | 57 ms
69,232 KB |
testcase_22 | AC | 419 ms
81,432 KB |
testcase_23 | AC | 410 ms
81,408 KB |
testcase_24 | AC | 415 ms
79,548 KB |
testcase_25 | AC | 418 ms
81,536 KB |
testcase_26 | AC | 422 ms
79,676 KB |
testcase_27 | AC | 96 ms
78,592 KB |
testcase_28 | AC | 139 ms
78,336 KB |
testcase_29 | AC | 110 ms
78,592 KB |
testcase_30 | AC | 113 ms
77,668 KB |
testcase_31 | AC | 107 ms
78,592 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() #print(base_d) pos = 0 res = [0 for i in range(N)] for d in base_d: n = d.bit_length() tmp = d & 1 for i in range(pos): tmp += d>>(i+1) & res[i] tmp %= 2 #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 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