結果
問題 | No.1421 国勢調査 (Hard) |
ユーザー | convexineq |
提出日時 | 2021-03-08 00:40:16 |
言語 | PyPy3 (7.3.15) |
結果 |
RE
|
実行時間 | - |
コード長 | 876 bytes |
コンパイル時間 | 204 ms |
コンパイル使用メモリ | 82,176 KB |
実行使用メモリ | 77,056 KB |
最終ジャッジ日時 | 2024-04-17 16:46:23 |
合計ジャッジ時間 | 6,729 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 33 ms
51,968 KB |
testcase_01 | AC | 34 ms
51,968 KB |
testcase_02 | RE | - |
testcase_03 | RE | - |
testcase_04 | RE | - |
testcase_05 | RE | - |
testcase_06 | RE | - |
testcase_07 | RE | - |
testcase_08 | RE | - |
testcase_09 | RE | - |
testcase_10 | RE | - |
testcase_11 | RE | - |
testcase_12 | AC | 35 ms
52,616 KB |
testcase_13 | AC | 35 ms
51,968 KB |
testcase_14 | AC | 36 ms
52,480 KB |
testcase_15 | AC | 36 ms
52,096 KB |
testcase_16 | RE | - |
testcase_17 | RE | - |
testcase_18 | RE | - |
testcase_19 | AC | 35 ms
52,352 KB |
testcase_20 | AC | 34 ms
52,480 KB |
testcase_21 | RE | - |
testcase_22 | AC | 117 ms
76,928 KB |
testcase_23 | AC | 118 ms
76,556 KB |
testcase_24 | AC | 115 ms
76,544 KB |
testcase_25 | AC | 119 ms
76,692 KB |
testcase_26 | AC | 115 ms
76,672 KB |
testcase_27 | AC | 106 ms
77,036 KB |
testcase_28 | AC | 106 ms
76,544 KB |
testcase_29 | AC | 107 ms
77,056 KB |
testcase_30 | AC | 109 ms
76,416 KB |
testcase_31 | AC | 106 ms
76,416 KB |
ソースコード
def solve_linear_equation_F2_col(A,b): assert len(A)==len(b) n = len(A) for i in range(n): idx = max(range(i,n),key=lambda x:A[x]) if A[idx]==0: rank = i break if idx != i: A[i],A[idx] = A[idx],A[i] b[i],b[idx] = b[idx],b[i] for j in range(n): if i != j and A[j] > A[j]^A[i]: A[j] ^= A[i] b[j] ^= b[i] else: rank = n if any(b[i] for i in range(rank,n)): return [-1] ans = [0]*n for i in range(rank): ans[A[i].bit_length()-1] = b[i] return ans n,m = map(int,input().split()) A = [0]*m Y = [0]*m for i in range(m): _ = int(input()) *a, = map(int,input().split()) for ai in a: A[i] |= 1<<(ai-1) Y[i] = int(input()) x = solve_linear_equation_F2_col(A,Y) print(*x,sep="\n")