結果
問題 | No.2375 watasou and hibit's baseball |
ユーザー | poyon |
提出日時 | 2023-06-22 20:37:47 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 692 ms / 2,000 ms |
コード長 | 1,624 bytes |
コンパイル時間 | 277 ms |
コンパイル使用メモリ | 82,124 KB |
実行使用メモリ | 120,192 KB |
最終ジャッジ日時 | 2024-07-08 08:50:40 |
合計ジャッジ時間 | 9,577 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 41 ms
52,224 KB |
testcase_01 | AC | 43 ms
51,968 KB |
testcase_02 | AC | 43 ms
52,480 KB |
testcase_03 | AC | 225 ms
95,488 KB |
testcase_04 | AC | 55 ms
61,824 KB |
testcase_05 | AC | 51 ms
60,544 KB |
testcase_06 | AC | 692 ms
120,192 KB |
testcase_07 | AC | 40 ms
52,096 KB |
testcase_08 | AC | 115 ms
83,584 KB |
testcase_09 | AC | 45 ms
52,096 KB |
testcase_10 | AC | 41 ms
52,736 KB |
testcase_11 | AC | 76 ms
71,936 KB |
testcase_12 | AC | 267 ms
119,552 KB |
testcase_13 | AC | 180 ms
95,744 KB |
testcase_14 | AC | 41 ms
52,480 KB |
testcase_15 | AC | 145 ms
80,256 KB |
testcase_16 | AC | 119 ms
77,824 KB |
testcase_17 | AC | 246 ms
119,680 KB |
testcase_18 | AC | 43 ms
52,864 KB |
testcase_19 | AC | 42 ms
52,096 KB |
testcase_20 | AC | 75 ms
71,936 KB |
testcase_21 | AC | 255 ms
119,552 KB |
testcase_22 | AC | 41 ms
52,352 KB |
testcase_23 | AC | 237 ms
119,936 KB |
testcase_24 | AC | 231 ms
119,552 KB |
testcase_25 | AC | 40 ms
52,224 KB |
testcase_26 | AC | 320 ms
119,680 KB |
testcase_27 | AC | 346 ms
119,680 KB |
testcase_28 | AC | 373 ms
119,808 KB |
testcase_29 | AC | 423 ms
119,808 KB |
testcase_30 | AC | 429 ms
119,808 KB |
testcase_31 | AC | 400 ms
119,680 KB |
testcase_32 | AC | 434 ms
119,808 KB |
testcase_33 | AC | 363 ms
119,808 KB |
testcase_34 | AC | 341 ms
119,552 KB |
testcase_35 | AC | 435 ms
119,808 KB |
testcase_36 | AC | 415 ms
119,680 KB |
testcase_37 | AC | 353 ms
119,936 KB |
testcase_38 | AC | 247 ms
119,680 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()