結果
問題 | No.506 限られたジャパリまん |
ユーザー | sue_charo |
提出日時 | 2017-06-01 22:54:43 |
言語 | Python3 (3.12.2 + numpy 1.26.4 + scipy 1.12.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,953 bytes |
コンパイル時間 | 121 ms |
コンパイル使用メモリ | 12,928 KB |
実行使用メモリ | 11,776 KB |
最終ジャッジ日時 | 2024-06-28 04:17:50 |
合計ジャッジ時間 | 3,086 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 36 ms
11,648 KB |
testcase_01 | AC | 36 ms
11,648 KB |
testcase_02 | AC | 37 ms
11,648 KB |
testcase_03 | AC | 37 ms
11,648 KB |
testcase_04 | AC | 39 ms
11,648 KB |
testcase_05 | AC | 36 ms
11,520 KB |
testcase_06 | AC | 36 ms
11,392 KB |
testcase_07 | AC | 39 ms
11,520 KB |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | AC | 255 ms
11,520 KB |
testcase_12 | AC | 168 ms
11,776 KB |
testcase_13 | AC | 37 ms
11,520 KB |
testcase_14 | WA | - |
testcase_15 | WA | - |
testcase_16 | WA | - |
testcase_17 | AC | 42 ms
11,648 KB |
testcase_18 | AC | 44 ms
11,520 KB |
testcase_19 | AC | 56 ms
11,520 KB |
testcase_20 | AC | 89 ms
11,520 KB |
testcase_21 | AC | 50 ms
11,776 KB |
testcase_22 | AC | 101 ms
11,520 KB |
testcase_23 | AC | 77 ms
11,520 KB |
testcase_24 | AC | 40 ms
11,648 KB |
ソースコード
# coding: utf-8 import array, bisect, collections, copy, heapq, itertools, math, random, re, string, sys, time sys.setrecursionlimit(10 ** 7) INF = 10 ** 20 MOD = 10 ** 9 + 7 def II(): return int(input()) def ILI(): return list(map(int, input().split())) def IAI(LINE): return [ILI() for __ in range(LINE)] def IDI(): return {key: value for key, value in ILI()} def nCk(n, k): return math.factorial(n) // (math.factorial(n - k) * math.factorial(k)) def read(): H, W, K, P = ILI() ani = [] for __ in range(K): x, y, name = input().split() ani.append((int(x), int(y), str(name))) return (H, W, K, P, ani) def solve(H, W, K, P, ani): ans_num = 0 ans_ind = 0 dif_k = K - P for ani_ind in itertools.combinations(range(K), dif_k): board = [[-1] * (W + 1) for __ in range(H + 1)] for ind in ani_ind: x, y, name = ani[ind] board[x][y] = 0 for h in range(H + 1): if board[h][0] == 0: break board[h][0] = 1 for w in range(W + 1): if board[0][w] == 0: break board[0][w] = 1 for w in range(1, W + 1): for h in range(1, H + 1): if board[h][w] == 0: continue else: board[h][w] = board[h - 1][w] + board[h][w - 1] if ans_num < board[H][W]: ans_num = board[H][W] ans_ind = ani_ind if ans_num == 0: return 0 else: ans = [] ans.append(ans_num % MOD) for ind in range(K): if ind in ans_ind: continue x, y, name = ani[ind] ans.append(name) return ans def main(): params = read() ans = solve(*params) if isinstance(ans, int): print(ans) else: for a in ans: print(a) if __name__ == "__main__": main()