結果
問題 | No.2375 watasou and hibit's baseball |
ユーザー | LyricalMaestro |
提出日時 | 2024-12-13 03:24:50 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 885 ms / 2,000 ms |
コード長 | 2,203 bytes |
コンパイル時間 | 2,536 ms |
コンパイル使用メモリ | 81,792 KB |
実行使用メモリ | 124,336 KB |
最終ジャッジ日時 | 2024-12-13 03:25:08 |
合計ジャッジ時間 | 15,172 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 41 ms
51,840 KB |
testcase_01 | AC | 40 ms
52,096 KB |
testcase_02 | AC | 40 ms
51,968 KB |
testcase_03 | AC | 440 ms
98,832 KB |
testcase_04 | AC | 59 ms
63,872 KB |
testcase_05 | AC | 53 ms
62,976 KB |
testcase_06 | AC | 885 ms
123,432 KB |
testcase_07 | AC | 40 ms
51,840 KB |
testcase_08 | AC | 112 ms
83,256 KB |
testcase_09 | AC | 39 ms
52,224 KB |
testcase_10 | AC | 40 ms
52,608 KB |
testcase_11 | AC | 92 ms
77,568 KB |
testcase_12 | AC | 480 ms
122,976 KB |
testcase_13 | AC | 256 ms
96,740 KB |
testcase_14 | AC | 38 ms
52,224 KB |
testcase_15 | AC | 378 ms
84,112 KB |
testcase_16 | AC | 190 ms
79,436 KB |
testcase_17 | AC | 334 ms
120,344 KB |
testcase_18 | AC | 40 ms
52,224 KB |
testcase_19 | AC | 38 ms
52,096 KB |
testcase_20 | AC | 81 ms
77,868 KB |
testcase_21 | AC | 375 ms
120,880 KB |
testcase_22 | AC | 39 ms
52,352 KB |
testcase_23 | AC | 290 ms
119,296 KB |
testcase_24 | AC | 282 ms
119,296 KB |
testcase_25 | AC | 39 ms
52,480 KB |
testcase_26 | AC | 531 ms
122,024 KB |
testcase_27 | AC | 635 ms
122,628 KB |
testcase_28 | AC | 607 ms
122,596 KB |
testcase_29 | AC | 594 ms
121,788 KB |
testcase_30 | AC | 787 ms
124,336 KB |
testcase_31 | AC | 706 ms
123,256 KB |
testcase_32 | AC | 784 ms
123,788 KB |
testcase_33 | AC | 658 ms
123,624 KB |
testcase_34 | AC | 560 ms
122,652 KB |
testcase_35 | AC | 631 ms
122,344 KB |
testcase_36 | AC | 563 ms
122,076 KB |
testcase_37 | AC | 623 ms
122,488 KB |
testcase_38 | AC | 303 ms
119,296 KB |
ソースコード
# https://yukicoder.me/problems/no/2375 def dist(from_i, to_j, xyk): xi, yi, _ = xyk[from_i] xj, yj, _ = xyk[to_j] return abs(xi - xj) + abs(yi - yj) def diff_speed(from_i, to_j, xyk): _, _, ki = xyk[from_i] _, _, kj = xyk[to_j] return abs(ki - kj) def main(): N, A, B = map(int, input().split()) xyk = [] for _ in range(N): x, y, k = map(int, input().split()) xyk.append((x, y, k)) bits = [[[False for _ in range(N)] for _ in range(N)] for _ in range(2 ** N)] # 2投目まで for i in range(N): for j in range(N): if i != j: if dist(i, j, xyk) >= A or diff_speed(i, j, xyk) >= B: bits[(1 << i) | (1 << j)][i][j] = True bit_map = {} for bit in range(2 ** N): bit_count = 0 for i in range(N): if bit & (1 << i) > 0: bit_count += 1 if bit_count >= 2: if bit_count not in bit_map: bit_map[bit_count] = [] bit_map[bit_count].append(bit) for bit_count in range(2, N): for bit in bit_map[bit_count]: for from_i in range(N): for from_j in range(N): if from_i == from_j: continue mask = (1 << from_i) & (1 << from_j) if bit & mask == mask and bits[bit][from_i][from_j]: for to_k in range(N): if bit & (1 << to_k) == 0: if diff_speed(from_j, to_k, xyk) >= B or (dist(from_i, to_k, xyk) + dist(from_j, to_k, xyk) >= A): new_bit = bit | (1 << to_k) bits[new_bit][from_j][to_k] = True answer = 1 for bit_count in range(2, N + 1): for bit in bit_map[bit_count]: is_ok = False for i in range(N): for j in range(N): if bits[bit][i][j]: is_ok = True if is_ok: answer = max(answer, bit_count) print(answer) if __name__ == "__main__": main()