結果
問題 |
No.943 取り調べ
|
ユーザー |
|
提出日時 | 2019-11-14 22:13:54 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 177 ms / 1,206 ms |
コード長 | 669 bytes |
コンパイル時間 | 194 ms |
コンパイル使用メモリ | 82,244 KB |
実行使用メモリ | 76,112 KB |
最終ジャッジ日時 | 2024-09-24 22:57:52 |
合計ジャッジ時間 | 2,578 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 24 |
ソースコード
n = int(input()) counton = [0]*n for i in range(n): b = input().split() for j in range(n): counton[i] += 1<<j if b[j]=="1" else 0 a = list(map(int, input().split())) ans = sum(a) for i in range(2**n): tmp = 0 for j in range(n): tmp += a[j] if ((i>>j)&1) == 1 else 0 # 高速化出来る if tmp >= ans: continue lie, confess, k = i, 0, -1 while k+1 < n: k += 1 if ((confess>>k)&1) == 1: continue if (lie&counton[k]) == counton[k]: confess |= 1<<k lie |= 1<<k k = -1 if confess == (1<<n)-1: ans = tmp print(ans)