Example Input 2 2 2 4 0 0 0 1 1 0 1 0 1 0 1 1 Output 4
- User
Example Input
2 2 2 4 0 0 0 1 1 0 1 0 1 0 1 1
Output
4
Assistant
pythonimport sys from collections import deque n, m, k, q = map(int, sys.stdin.readline().split()) cubes = set() for _ in range(q): x, y, z = map(int, sys.stdin.readline().split()) cubes.add((x, y, z)) visited = set() count = 0 directions = [(-1, 0, 0), (1, 0, 0), (0, -1, 0), (0, 1, 0), (0, 0, -1), (0, 0, 1)] for cube in cubes: if cube not in visited: count += 1 queue = deque([cube]) visited.add(cube) while queue: x, y, z = queue.popleft() for dx, dy, dz in directions: neighbor = (x + dx, y + dy, z + dz) if neighbor in cubes and neighbor not in visited: visited.add(neighbor) queue.append(neighbor) print(count)
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.