結果
問題 | No.2375 watasou and hibit's baseball |
ユーザー | poyon |
提出日時 | 2023-06-27 18:44:06 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 626 ms / 2,000 ms |
コード長 | 1,624 bytes |
コンパイル時間 | 3,920 ms |
コンパイル使用メモリ | 81,836 KB |
実行使用メモリ | 120,472 KB |
最終ジャッジ日時 | 2024-07-08 08:54:23 |
合計ジャッジ時間 | 11,332 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 33 ms
52,096 KB |
testcase_01 | AC | 35 ms
52,352 KB |
testcase_02 | AC | 91 ms
52,608 KB |
testcase_03 | AC | 197 ms
95,616 KB |
testcase_04 | AC | 45 ms
62,336 KB |
testcase_05 | AC | 41 ms
60,544 KB |
testcase_06 | AC | 626 ms
120,472 KB |
testcase_07 | AC | 35 ms
52,096 KB |
testcase_08 | AC | 90 ms
83,712 KB |
testcase_09 | AC | 32 ms
52,352 KB |
testcase_10 | AC | 43 ms
52,608 KB |
testcase_11 | AC | 56 ms
72,576 KB |
testcase_12 | AC | 227 ms
120,004 KB |
testcase_13 | AC | 154 ms
95,488 KB |
testcase_14 | AC | 33 ms
52,224 KB |
testcase_15 | AC | 111 ms
80,244 KB |
testcase_16 | AC | 104 ms
77,876 KB |
testcase_17 | AC | 207 ms
119,808 KB |
testcase_18 | AC | 34 ms
52,480 KB |
testcase_19 | AC | 33 ms
52,480 KB |
testcase_20 | AC | 55 ms
72,064 KB |
testcase_21 | AC | 217 ms
119,808 KB |
testcase_22 | AC | 32 ms
52,608 KB |
testcase_23 | AC | 198 ms
119,808 KB |
testcase_24 | AC | 200 ms
119,468 KB |
testcase_25 | AC | 33 ms
52,224 KB |
testcase_26 | AC | 280 ms
119,680 KB |
testcase_27 | AC | 301 ms
120,056 KB |
testcase_28 | AC | 331 ms
120,016 KB |
testcase_29 | AC | 355 ms
119,936 KB |
testcase_30 | AC | 392 ms
119,612 KB |
testcase_31 | AC | 353 ms
119,680 KB |
testcase_32 | AC | 393 ms
119,856 KB |
testcase_33 | AC | 320 ms
119,680 KB |
testcase_34 | AC | 310 ms
119,808 KB |
testcase_35 | AC | 390 ms
120,292 KB |
testcase_36 | AC | 351 ms
120,064 KB |
testcase_37 | AC | 308 ms
119,828 KB |
testcase_38 | AC | 216 ms
119,424 KB |
ソースコード
import sys input = sys.stdin.readline def main(): N, A, B = map(int, input().split()) X, Y, K = [0] * N, [0] * N, [0] * N for i in range(N): X[i], Y[i], K[i] = map(int, input().split()) ok = [[[False] * N for _ in range(N)] for _ in range(N)] # a -> b -> c for a in range(N): for b in range(N): for c in range(N): if a == b or a == c or b == c: continue d = abs(X[c] - X[a]) + abs(Y[c] - Y[a]) + abs(X[c] - X[b]) + abs(Y[c] - Y[b]) v = abs(K[c] - K[b]) if d >= A or v >= B: ok[a][b][c] = True dp = [[[False] * N for _ in range(N)] for _ in range(1 << N)] # a -> b for a in range(N): for b in range(N): if a == b: continue d = abs(X[b] - X[a]) + abs(Y[b] - Y[a]) v = abs(K[b] - K[a]) if d >= A or v >= B: dp[(1 << a) + (1 << b)][a][b] = True for S in range(1, 1 << N): for a in range(N): if ((S >> a) & 1) == 0: continue for b in range(N): if ((S >> b) & 1) == 0: continue if not dp[S][a][b]: continue for c in range(N): if ((S >> c) & 1) == 1: continue if not ok[a][b][c]: continue dp[S + (1 << c)][b][c] = True ans = 1 for S in range(1, 1 << N): for a in range(N): for b in range(N): if dp[S][a][b]: ans = max(ans, bin(S).count("1")) print(ans) if __name__ == "__main__": main()