結果
| 問題 |
No.506 限られたジャパリまん
|
| コンテスト | |
| ユーザー |
h_noson
|
| 提出日時 | 2017-06-15 22:44:58 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,006 bytes |
| コンパイル時間 | 87 ms |
| コンパイル使用メモリ | 12,544 KB |
| 実行使用メモリ | 17,692 KB |
| 最終ジャッジ日時 | 2024-06-28 04:18:16 |
| 合計ジャッジ時間 | 3,657 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 4 TLE * 1 -- * 20 |
ソースコード
def popcount(x):
ret = 0
while x:
x &= x-1
ret += 1
return ret
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
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]
if b < w and m[a][b+1]:
s[a][b+1] += s[a][b]
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 mx > 0:
for j in range(k):
if bits&1<<j:
print(n[j])
h_noson