結果

問題 No.1056 2D Lamps
ユーザー convexineqconvexineq
提出日時 2020-05-16 17:11:42
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 1,013 bytes
コンパイル時間 152 ms
コンパイル使用メモリ 11,940 KB
実行使用メモリ 28,116 KB
最終ジャッジ日時 2023-10-23 19:34:36
合計ジャッジ時間 10,000 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 28 ms
10,264 KB
testcase_02 AC 28 ms
10,264 KB
testcase_03 AC 821 ms
28,116 KB
testcase_04 AC 820 ms
28,116 KB
testcase_05 AC 819 ms
28,116 KB
testcase_06 AC 811 ms
28,116 KB
testcase_07 AC 852 ms
28,116 KB
testcase_08 AC 847 ms
28,116 KB
testcase_09 AC 403 ms
27,324 KB
testcase_10 AC 613 ms
27,324 KB
testcase_11 AC 815 ms
28,116 KB
testcase_12 AC 819 ms
28,116 KB
testcase_13 AC 28 ms
10,264 KB
testcase_14 AC 32 ms
10,280 KB
testcase_15 AC 33 ms
10,288 KB
testcase_16 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

def get_basis(a):
    L = len(a)
    top = []
    for i in range(L):
        idx = max(range(i,L),key=lambda x:a[x].bit_length())
        a[i],a[idx] = a[idx],a[i]
        if a[i]==0: break
        t = a[i].bit_length()-1
        top.append(t)
        for j in range(i+1,L):
            if a[j]>>t&1: a[j]^=a[i]
    else: i+=1            
    return a[:i],top

def normalize(v,basis,top):
    for e,l in zip(basis,top):
        if v&(1<<l): v ^= e
    return v

import sys
n,m = map(int,input().split())
mat = sys.stdin.read().translate(str.maketrans('.#','01','\n'))
#生成系
p = [0]*n
q = [0]*n
r = [0]*2*n
s = [0]*2*n
for i in range(n):
    for j in range(n):
        v = 1<<(n*i+j)
        p[i] ^= v
        q[j] ^= v
        r[i+j] ^= v
        s[i-j+n] ^= v
basis,top = get_basis(p+q+r+s)
#top = [i.bit_length()-1 for i in basis]

res = [normalize(int(mat[T*n*n:(T+1)*n*n],2),basis,top) for T in range(m)]
for i in range(m-1): print("".join("01"[res[i]==res[j]] for j in range(i+1,m)))


if n==5: print(1)
0