結果
問題 | No.2375 watasou and hibit's baseball |
ユーザー | mo124121 |
提出日時 | 2023-07-07 23:10:44 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,715 bytes |
コンパイル時間 | 516 ms |
コンパイル使用メモリ | 82,660 KB |
実行使用メモリ | 124,872 KB |
最終ジャッジ日時 | 2024-07-21 19:34:18 |
合計ジャッジ時間 | 7,423 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 40 ms
54,196 KB |
testcase_01 | AC | 40 ms
53,756 KB |
testcase_02 | AC | 40 ms
54,108 KB |
testcase_03 | WA | - |
testcase_04 | WA | - |
testcase_05 | WA | - |
testcase_06 | WA | - |
testcase_07 | AC | 41 ms
54,500 KB |
testcase_08 | AC | 86 ms
82,872 KB |
testcase_09 | AC | 41 ms
53,420 KB |
testcase_10 | AC | 41 ms
53,064 KB |
testcase_11 | AC | 56 ms
67,388 KB |
testcase_12 | AC | 214 ms
124,264 KB |
testcase_13 | WA | - |
testcase_14 | WA | - |
testcase_15 | AC | 93 ms
80,528 KB |
testcase_16 | AC | 71 ms
72,412 KB |
testcase_17 | AC | 205 ms
124,728 KB |
testcase_18 | AC | 41 ms
53,052 KB |
testcase_19 | AC | 40 ms
53,240 KB |
testcase_20 | AC | 57 ms
67,404 KB |
testcase_21 | WA | - |
testcase_22 | AC | 40 ms
53,240 KB |
testcase_23 | AC | 198 ms
123,960 KB |
testcase_24 | WA | - |
testcase_25 | AC | 41 ms
52,792 KB |
testcase_26 | WA | - |
testcase_27 | AC | 214 ms
124,484 KB |
testcase_28 | WA | - |
testcase_29 | WA | - |
testcase_30 | WA | - |
testcase_31 | WA | - |
testcase_32 | WA | - |
testcase_33 | AC | 229 ms
124,660 KB |
testcase_34 | WA | - |
testcase_35 | WA | - |
testcase_36 | WA | - |
testcase_37 | AC | 250 ms
124,348 KB |
testcase_38 | WA | - |
ソースコード
from itertools import permutations N, A, B = map(int, input().split()) XYK = [] for _ in range(N): x, y, k = map(int, input().split()) XYK.append((x, y, k)) coef = [[[0] * (N + 1) for _ in range(N + 1)] for _ in range(N + 1)] def dist(z1, z2): return abs(z1[0] - z2[0]) + abs(z1[1] - z2[1]) for (i, zi), (j, zj) in permutations(enumerate(XYK), 2): if A <= dist(zi, zj): coef[N][i][j] = 1 if B <= abs(zi[2] - zj[2]): for k in range(N + 1): coef[N][i][j] = 1 for (i, zi), (j, zj), (k, zk) in permutations(enumerate(XYK), 3): if A <= dist(zi, zj) + dist(zj, zk): coef[i][j][k] = 1 dp = [[[0] * (N + 1) for _ in range(N + 1)] for _ in range(1 << N)] for i in range(N): dp[1 << i][N][i] = 1 def popcount(n): c = (n & 0x5555555555555555) + ((n >> 1) & 0x5555555555555555) c = (c & 0x3333333333333333) + ((c >> 2) & 0x3333333333333333) c = (c & 0x0F0F0F0F0F0F0F0F) + ((c >> 4) & 0x0F0F0F0F0F0F0F0F) c = (c & 0x00FF00FF00FF00FF) + ((c >> 8) & 0x00FF00FF00FF00FF) c = (c & 0x0000FFFF0000FFFF) + ((c >> 16) & 0x0000FFFF0000FFFF) c = (c & 0x00000000FFFFFFFF) + ((c >> 32) & 0x00000000FFFFFFFF) return c ans = 0 for group in range(1, 1 << N): flag = False for i in range(N + 1): for j in range(N): if i == j: continue if dp[group][i][j] == 0: continue flag = True for k in range(N): nxt = group | (1 << k) if nxt == group: continue if coef[i][j][k]: dp[nxt][j][k] = 1 if flag: ans = max(ans, popcount(group)) print(ans)