結果
問題 | No.2911 位相の公理 |
ユーザー | vwxyz |
提出日時 | 2024-10-04 22:03:42 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 472 ms / 2,000 ms |
コード長 | 2,488 bytes |
コンパイル時間 | 185 ms |
コンパイル使用メモリ | 82,176 KB |
実行使用メモリ | 151,432 KB |
最終ジャッジ日時 | 2024-10-04 22:03:46 |
合計ジャッジ時間 | 3,395 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 39 ms
52,480 KB |
testcase_01 | AC | 40 ms
52,608 KB |
testcase_02 | AC | 40 ms
52,352 KB |
testcase_03 | AC | 37 ms
52,480 KB |
testcase_04 | AC | 37 ms
52,480 KB |
testcase_05 | AC | 38 ms
53,248 KB |
testcase_06 | AC | 39 ms
52,480 KB |
testcase_07 | AC | 38 ms
52,096 KB |
testcase_08 | AC | 40 ms
52,480 KB |
testcase_09 | AC | 41 ms
52,992 KB |
testcase_10 | AC | 40 ms
52,736 KB |
testcase_11 | AC | 40 ms
52,736 KB |
testcase_12 | AC | 41 ms
52,736 KB |
testcase_13 | AC | 40 ms
52,224 KB |
testcase_14 | AC | 40 ms
52,224 KB |
testcase_15 | AC | 39 ms
52,224 KB |
testcase_16 | AC | 51 ms
61,312 KB |
testcase_17 | AC | 47 ms
52,480 KB |
testcase_18 | AC | 73 ms
72,704 KB |
testcase_19 | AC | 101 ms
77,184 KB |
testcase_20 | AC | 444 ms
151,044 KB |
testcase_21 | AC | 472 ms
151,300 KB |
testcase_22 | AC | 94 ms
82,900 KB |
testcase_23 | AC | 451 ms
151,432 KB |
ソースコード
def AND_Convolution(polynomial0,polynomial1,mod=0): n=(max(len(polynomial0),len(polynomial1))-1).bit_length() polynomial0=[x for x in polynomial0]+[0]*((1<<n)-len(polynomial0)) polynomial1=[x for x in polynomial1]+[0]*((1<<n)-len(polynomial1)) for i in range(n): for bit in range(1<<n): if not bit&1<<i: polynomial0[bit]+=polynomial0[bit^1<<i] polynomial1[bit]+=polynomial1[bit^1<<i] if mod: polynomial0[bit]%=mod polynomial1[bit]%=mod if mod: convolution=[x*y%mod for x,y in zip(polynomial0,polynomial1)] else: convolution=[x*y for x,y in zip(polynomial0,polynomial1)] for i in range(n): for bit in range(1<<n): if not bit&1<<i: convolution[bit]-=convolution[bit^1<<i] if mod: convolution[bit]%=mod return convolution def OR_Convolution(polynomial0,polynomial1,mod=0): n=(max(len(polynomial0),len(polynomial1))-1).bit_length() polynomial0=[x for x in polynomial0]+[0]*((1<<n)-len(polynomial0)) polynomial1=[x for x in polynomial1]+[0]*((1<<n)-len(polynomial1)) for i in range(n): for bit in range(1<<n): if bit&1<<i: polynomial0[bit]+=polynomial0[bit^1<<i] polynomial1[bit]+=polynomial1[bit^1<<i] if mod: polynomial0[bit]%=mod polynomial1[bit]%=mod if mod: convolution=[x*y%mod for x,y in zip(polynomial0,polynomial1)] else: convolution=[x*y for x,y in zip(polynomial0,polynomial1)] for i in range(n): for bit in range(1<<n): if bit&1<<i: convolution[bit]-=convolution[bit^1<<i] if mod: convolution[bit]%=mod return convolution N,M=map(int,input().split()) N,M=M,N S=[] for n in range(N): s=list(map(int,list(input()))) bit=0 for m in range(M): bit|=s[m]<<m S.append(bit) if not (1<<M)-1 in S: print("No") exit() if not 0 in S: print("No") exit() C=[0]*(1<<M) for s in S: C[s]=1 CC=AND_Convolution(C,C) for n in range(1<<M): if CC[n]: CC[n]=1 if C!=CC: print("No") exit() C=[0]*(1<<M) for s in S: C[s]=1 C[0]=1 for _ in range(20): CC=OR_Convolution(C,C) for n in range(1<<M): if CC[n]: CC[n]=1 if C!=CC: print("No") exit() print("Yes")