結果
問題 | No.2375 watasou and hibit's baseball |
ユーザー | mo124121 |
提出日時 | 2023-07-07 23:15:38 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 352 ms / 2,000 ms |
コード長 | 1,715 bytes |
コンパイル時間 | 247 ms |
コンパイル使用メモリ | 82,536 KB |
実行使用メモリ | 124,900 KB |
最終ジャッジ日時 | 2024-07-21 19:38:09 |
合計ジャッジ時間 | 6,594 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 33 ms
52,480 KB |
testcase_01 | AC | 33 ms
52,736 KB |
testcase_02 | AC | 36 ms
52,608 KB |
testcase_03 | AC | 139 ms
98,304 KB |
testcase_04 | AC | 42 ms
60,800 KB |
testcase_05 | AC | 42 ms
60,544 KB |
testcase_06 | AC | 352 ms
124,476 KB |
testcase_07 | AC | 35 ms
52,096 KB |
testcase_08 | AC | 76 ms
83,200 KB |
testcase_09 | AC | 35 ms
52,480 KB |
testcase_10 | AC | 35 ms
52,864 KB |
testcase_11 | AC | 47 ms
66,432 KB |
testcase_12 | AC | 183 ms
124,160 KB |
testcase_13 | AC | 124 ms
98,432 KB |
testcase_14 | AC | 35 ms
52,096 KB |
testcase_15 | AC | 84 ms
80,640 KB |
testcase_16 | AC | 64 ms
71,936 KB |
testcase_17 | AC | 179 ms
124,680 KB |
testcase_18 | AC | 36 ms
52,480 KB |
testcase_19 | AC | 36 ms
52,480 KB |
testcase_20 | AC | 47 ms
66,304 KB |
testcase_21 | AC | 180 ms
124,160 KB |
testcase_22 | AC | 36 ms
52,608 KB |
testcase_23 | AC | 175 ms
124,028 KB |
testcase_24 | AC | 176 ms
124,116 KB |
testcase_25 | AC | 35 ms
52,480 KB |
testcase_26 | AC | 218 ms
124,900 KB |
testcase_27 | AC | 216 ms
124,544 KB |
testcase_28 | AC | 226 ms
124,584 KB |
testcase_29 | AC | 257 ms
124,568 KB |
testcase_30 | AC | 247 ms
124,544 KB |
testcase_31 | AC | 236 ms
124,368 KB |
testcase_32 | AC | 252 ms
124,288 KB |
testcase_33 | AC | 234 ms
124,568 KB |
testcase_34 | AC | 214 ms
124,672 KB |
testcase_35 | AC | 265 ms
124,544 KB |
testcase_36 | AC | 255 ms
124,800 KB |
testcase_37 | AC | 225 ms
124,416 KB |
testcase_38 | AC | 175 ms
124,160 KB |
ソースコード
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[k][i][j] = 1 for (i, zi), (j, zj), (k, zk) in permutations(enumerate(XYK), 3): if A <= dist(zi, zk) + 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)