# 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()