結果
問題 | No.506 限られたジャパリまん |
ユーザー | h_noson |
提出日時 | 2017-06-15 22:52:05 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,108 bytes |
コンパイル時間 | 1,274 ms |
コンパイル使用メモリ | 86,760 KB |
実行使用メモリ | 78,344 KB |
最終ジャッジ日時 | 2023-09-10 12:54:43 |
合計ジャッジ時間 | 10,325 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge14 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 72 ms
71,224 KB |
testcase_01 | AC | 72 ms
71,264 KB |
testcase_02 | AC | 94 ms
76,524 KB |
testcase_03 | AC | 72 ms
71,328 KB |
testcase_04 | WA | - |
testcase_05 | WA | - |
testcase_06 | AC | 74 ms
71,308 KB |
testcase_07 | WA | - |
testcase_08 | AC | 303 ms
77,612 KB |
testcase_09 | AC | 184 ms
77,672 KB |
testcase_10 | AC | 125 ms
77,836 KB |
testcase_11 | WA | - |
testcase_12 | WA | - |
testcase_13 | AC | 76 ms
71,344 KB |
testcase_14 | WA | - |
testcase_15 | AC | 80 ms
71,288 KB |
testcase_16 | AC | 268 ms
77,848 KB |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | WA | - |
testcase_20 | WA | - |
testcase_21 | WA | - |
testcase_22 | WA | - |
testcase_23 | WA | - |
testcase_24 | AC | 104 ms
77,332 KB |
ソースコード
def popcount(x): ret = 0 while x: x &= x-1 ret += 1 return ret MOD = 10**9+7 h, w, k, p = map(int,input().split(' ')) x = [0] * k y = [0] * k n = [""] * k m = [[True] * (w+1) for i in range(h+1)] for i in range(k): a,b,n[i] = input().split(' ') x[i] = int(a) y[i] = int(b) m[x[i]][y[i]] = False mx = 0 bits = -1 for i in range(1<<k): if popcount(i) <= p: for j in range(k): if i&1<<j: m[x[j]][y[j]] = True s = [[0] * (w+1) for i in range(h+1)] s[0][0] = 1 for a in range(h+1): for b in range(w+1): if a < h and m[a+1][b]: s[a+1][b] += s[a][b] s[a+1][b] %= MOD if b < w and m[a][b+1]: s[a][b+1] += s[a][b] s[a][b+1] %= MOD if s[h][w] > mx: mx = s[h][w] bits = i for j in range(k): if i&1<<j: m[x[j]][y[j]] = False print(mx) if bits >= 0: for j in range(k): if bits&1<<j: print(n[j])