| 模型 | 模型答案 | 正确答案 |
|---|---|---|
| 金声玉亮2.0 | ```python import sys input = sys.stdin.read data = input().split() H = int(data[0]) W = int(data[1]) N = int(data[2]) grid = [['.' for _ in range(W)] for _ in range(H)] # Directions: 0: up, 1: right, 2: down, 3: left directions = [(-1, 0), (0, 1), (1, 0), (0, -1)] current_direction = 0 current_position = (0, 0) for _ in range(N): x, y = current_position if grid[x][y] == '.': grid[x][y] = '#' current_direction = (current_direction + 1) % 4 else: grid[x][y] = '.' current_direction = (current_direction - 1) % 4 dx, dy = directions[current_direction] current_position = ((x + dx) % H, (y + dy) % W) for row in grid: print(''.join(row)) ``` |
[{"input": "3 4 5\n", "output": ".#..\n##..\n....\n", "testtype": "stdin"}, {"input": "2 2 1000\n", "output": "..\n..\n", "testtype": "stdin"}, {"input": "10 10 10\n", "output": "##........\n##........\n..........\n..........\n..........\n..........\n..........\n..........\n..........\n#........#\n", "testtype": "stdin"}] |
| deepseek-r1 | ```python # YOUR CODE HERE H, W, N = map(int, input().split()) grid = [[False for _ in range(W)] for _ in range(H)] current_row, current_col = 0, 0 direction = 0 # 0: up, 1: right, 2: down, 3: left for _ in range(N): if grid[current_row][current_col]: grid[current_row][current_col] = False direction = (direction - 1) % 4 else: grid[current_row][current_col] = True direction = (direction + 1) % 4 if direction == 0: current_row = (current_row - 1) % H elif direction == 1: current_col = (current_col + 1) % W elif direction == 2: current_row = (current_row + 1) % H else: current_col = (current_col - 1) % W for row in grid: print(''.join('#' if cell else '.' for cell in row)) ``` |
[{"input": "3 4 5\n", "output": ".#..\n##..\n....\n", "testtype": "stdin"}, {"input": "2 2 1000\n", "output": "..\n..\n", "testtype": "stdin"}, {"input": "10 10 10\n", "output": "##........\n##........\n..........\n..........\n..........\n..........\n..........\n..........\n..........\n#........#\n", "testtype": "stdin"}] |
| gpto1 | ```python # YOUR CODE HERE H, W, N = map(int, input().split()) grid = [[False]*W for _ in range(H)] # Directions: Up, Right, Down, Left directions = [(-1, 0), (0, 1), (1, 0), (0, -1)] dir = 0 # Start facing up x, y = 0, 0 # Starting position (0-indexed) for _ in range(N): if not grid[x][y]: # Current cell is white grid[x][y] = True # Paint it black dir = (dir + 1) % 4 # Rotate 90 degrees clockwise else: # Current cell is black grid[x][y] = False # Paint it white dir = (dir - 1) % 4 # Rotate 90 degrees counterclockwise dx, dy = directions[dir] x = (x + dx) % H # Move to next cell (toroidal) y = (y + dy) % W # Output the grid for row in grid: line = ''.join('#' if cell else '.' for cell in row) print(line) ``` |
[{"input": "3 4 5\n", "output": ".#..\n##..\n....\n", "testtype": "stdin"}, {"input": "2 2 1000\n", "output": "..\n..\n", "testtype": "stdin"}, {"input": "10 10 10\n", "output": "##........\n##........\n..........\n..........\n..........\n..........\n..........\n..........\n..........\n#........#\n", "testtype": "stdin"}] |
| gpt-4o-2024-08-06 | ```python # YOUR CODE HERE def main(): import sys input = sys.stdin.read data = input().strip() H, W, N = map(int, data.split()) # Initialize the grid with all white cells grid = [['.' for _ in range(W)] for _ in range(H)] # Directions: 0 = up, 1 = right, 2 = down, 3 = left directions = [(-1, 0), (0, 1), (1, 0), (0, -1)] direction = 0 # Start facing upwards # Start position x, y = 0, 0 for _ in range(N): if grid[x][y] == '.': # If white, paint black, turn right, move forward grid[x][y] = '#' direction = (direction + 1) % 4 else: # If black, paint white, turn left, move forward grid[x][y] = '.' direction = (direction - 1) % 4 # Move forward in the current direction dx, dy = directions[direction] x = (x + dx) % H y = (y + dy) % W # Print the final grid for row in grid: print(''.join(row)) if __name__ == "__main__": main() ``` |
[{"input": "3 4 5\n", "output": ".#..\n##..\n....\n", "testtype": "stdin"}, {"input": "2 2 1000\n", "output": "..\n..\n", "testtype": "stdin"}, {"input": "10 10 10\n", "output": "##........\n##........\n..........\n..........\n..........\n..........\n..........\n..........\n..........\n#........#\n", "testtype": "stdin"}] |
| DeepSeek-Coder-V2-Lite-Instruct | ```python # YOUR CODE HERE def main(): import sys input = sys.stdin.read data = input().split() H, W, N = int(data[0]), int(data[1]), int(data[2]) # Initialize the grid grid = [['.' for _ in range(W)] for _ in range(H)] # Directions: up, right, down, left directions = [(-1, 0), (0, 1), (1, 0), (0, -1)] direction_index = 0 # Start facing upwards # Current position x, y = 0, 0 for _ in range(N): current_cell = grid[x][y] if current_cell == '.': # Repaint black and rotate clockwise grid[x][y] = '#' direction_index = (direction_index + 1) % 4 else: # Repaint white and rotate counterclockwise grid[x][y] = '.' direction_index = (direction_index - 1) % 4 # Move forward in the current direction dx, dy = directions[direction_index] x = (x + dx) % H y = (y + dy) % W # Print the final grid for row in grid: print(''.join(row)) if __name__ == "__main__": main() ``` |
[{"input": "3 4 5\n", "output": ".#..\n##..\n....\n", "testtype": "stdin"}, {"input": "2 2 1000\n", "output": "..\n..\n", "testtype": "stdin"}, {"input": "10 10 10\n", "output": "##........\n##........\n..........\n..........\n..........\n..........\n..........\n..........\n..........\n#........#\n", "testtype": "stdin"}] |
| Meta-Llama-3.1-405B-Instruct-Turbo | ```python import sys H, W, N = map(int, sys.stdin.readline().split()) grid = [['.' for _ in range(W)] for _ in range(H)] x, y = 0, 0 dx, dy = [-1, 0, 1, 0], [0, 1, 0, -1] dir = 0 for _ in range(N): if grid[x][y] == '.': grid[x][y] = '#' dir = (dir + 1) % 4 else: grid[x][y] = '.' dir = (dir - 1) % 4 x = (x + dx[dir]) % H y = (y + dy[dir]) % W for row in grid: print(''.join(row)) ``` |
[{"input": "3 4 5\n", "output": ".#..\n##..\n....\n", "testtype": "stdin"}, {"input": "2 2 1000\n", "output": "..\n..\n", "testtype": "stdin"}, {"input": "10 10 10\n", "output": "##........\n##........\n..........\n..........\n..........\n..........\n..........\n..........\n..........\n#........#\n", "testtype": "stdin"}] |
| Meta-Llama-3.1-70B-Instruct-Turbo | ```python import sys H, W, N = map(int, sys.stdin.readline().split()) grid = [['.' for _ in range(W)] for _ in range(H)] x, y = 0, 0 dx, dy = 0, 1 for _ in range(N): if grid[x][y] == '.': grid[x][y] = '#' dx, dy = dy, -dx else: grid[x][y] = '.' dx, dy = -dy, dx x = (x + dx) % H y = (y + dy) % W for row in grid: print(''.join(row)) ``` |
[{"input": "3 4 5\n", "output": ".#..\n##..\n....\n", "testtype": "stdin"}, {"input": "2 2 1000\n", "output": "..\n..\n", "testtype": "stdin"}, {"input": "10 10 10\n", "output": "##........\n##........\n..........\n..........\n..........\n..........\n..........\n..........\n..........\n#........#\n", "testtype": "stdin"}] |
| Qwen2-72B-Instruct | ```python from collections import deque def solve(H, W, N): grid = [['.' for _ in range(W)] for _ in range(H)] directions = [(0, 1), (1, 0), (0, -1), (-1, 0)] # Right, Down, Left, Up direction = 3 # Start facing Up x, y = 0, 0 # Start at (1, 1) but indexing is 0-based for _ in range(N): if grid[x][y] == '.': grid[x][y] = '#' direction = (direction + 1) % 4 else: grid[x][y] = '.' direction = (direction - 1) % 4 dx, dy = directions[direction] x = (x + dx) % H y = (y + dy) % W for row in grid: print(''.join(row)) H, W, N = map(int, input().split()) solve(H, W, N) ``` ``` |
[{"input": "3 4 5\n", "output": ".#..\n##..\n....\n", "testtype": "stdin"}, {"input": "2 2 1000\n", "output": "..\n..\n", "testtype": "stdin"}, {"input": "10 10 10\n", "output": "##........\n##........\n..........\n..........\n..........\n..........\n..........\n..........\n..........\n#........#\n", "testtype": "stdin"}] |
| baichuan4 | ```python # YOUR CODE HERE import sys def print_grid(grid): for row in grid: print(''.join(row)) def simulate_movement(H, W, N): # Initialize the grid with '.' representing white cells grid = [['.' for _ in range(W)] for _ in range(H)] # Directions: Up, Right, Down, Left directions = [(-1, 0), (0, 1), (1, 0), (0, -1)] # Start position and direction x, y, d = 0, 0, 0 # x, y are 0-indexed for _ in range(N): if grid[x][y] == '.': # White cell grid[x][y] = '#' # Paint black d = (d + 1) % 4 # Rotate 90 degrees clockwise else: # Black cell grid[x][y] = '.' # Paint white d = (d - 1) % 4 # Rotate 90 degrees counterclockwise # Move forward nx, ny = (x + directions[d][0]) % H, (y + directions[d][1]) % W x, y = nx, ny print_grid(grid) # Read input from stdin H, W, N = map(int, sys.stdin.readline().split()) simulate_movement(H, W, N) ``` ``` |
[{"input": "3 4 5\n", "output": ".#..\n##..\n....\n", "testtype": "stdin"}, {"input": "2 2 1000\n", "output": "..\n..\n", "testtype": "stdin"}, {"input": "10 10 10\n", "output": "##........\n##........\n..........\n..........\n..........\n..........\n..........\n..........\n..........\n#........#\n", "testtype": "stdin"}] |
| doubao | ```python import numpy as np H, W, N = map(int, input().split()) grid = np.full((H, W), '.') direction = 0 # 0: up, 1: right, 2: down, 3: left row = 0 col = 0 for _ in range(N): if grid[row][col] == '.': grid[row][col] = '#' direction = (direction + 1) % 4 else: grid[row][col] = '.' direction = (direction - 1) % 4 if direction == 0: row = (row - 1 + H) % H elif direction == 1: col = (col + 1) % W elif direction == 2: row = (row + 1) % H elif direction == 3: col = (col - 1 + W) % W for i in range(H): print(''.join(grid[i])) ``` |
[{"input": "3 4 5\n", "output": ".#..\n##..\n....\n", "testtype": "stdin"}, {"input": "2 2 1000\n", "output": "..\n..\n", "testtype": "stdin"}, {"input": "10 10 10\n", "output": "##........\n##........\n..........\n..........\n..........\n..........\n..........\n..........\n..........\n#........#\n", "testtype": "stdin"}] |
| gpto1 | ```python # YOUR CODE HERE H, W, N = map(int, input().split()) grid = [[False]*W for _ in range(H)] # Directions: Up, Right, Down, Left directions = [(-1, 0), (0, 1), (1, 0), (0, -1)] dir = 0 # Start facing up x, y = 0, 0 # Starting position (0-indexed) for _ in range(N): if not grid[x][y]: # Current cell is white grid[x][y] = True # Paint it black dir = (dir + 1) % 4 # Rotate 90 degrees clockwise else: # Current cell is black grid[x][y] = False # Paint it white dir = (dir - 1) % 4 # Rotate 90 degrees counterclockwise dx, dy = directions[dir] x = (x + dx) % H # Move to next cell (toroidal) y = (y + dy) % W # Output the grid for row in grid: line = ''.join('#' if cell else '.' for cell in row) print(line) ``` |
[{"input": "3 4 5\n", "output": ".#..\n##..\n....\n", "testtype": "stdin"}, {"input": "2 2 1000\n", "output": "..\n..\n", "testtype": "stdin"}, {"input": "10 10 10\n", "output": "##........\n##........\n..........\n..........\n..........\n..........\n..........\n..........\n..........\n#........#\n", "testtype": "stdin"}] |
| kimi | ```python # YOUR CODE HERE (H, W, N) = map(int, input().split()) grid = [['.' for _ in range(W)] for _ in range(H)] dx = 0 dy = -1 x = 0 y = 0 for _ in range(N): if grid[y][x] == '.': grid[y][x] = '#' dx = -dy dy = dx else: grid[y][x] = '.' dx = dy dy = -dx x = (x + dx) % W y = (y + dy) % H for row in grid: print(''.join(row)) ``` |
[{"input": "3 4 5\n", "output": ".#..\n##..\n....\n", "testtype": "stdin"}, {"input": "2 2 1000\n", "output": "..\n..\n", "testtype": "stdin"}, {"input": "10 10 10\n", "output": "##........\n##........\n..........\n..........\n..........\n..........\n..........\n..........\n..........\n#........#\n", "testtype": "stdin"}] |
| minimax | ```python # YOUR CODE HERE from collections import deque def rotate_clockwise(pos): return (pos[1], -pos[0]) def rotate_counterclockwise(pos): return (-pos[1], pos[0]) def move_forward(pos, direction): return (pos[0] + direction[0], pos[1] + direction[1]) def get_opposite_direction(direction): return (-direction[0], -direction[1]) def paint_grid(H, W, N): grid = [['.' for _ in range(W)] for _ in range(H)] pos = (0, 0) direction = (0, -1) # facing upwards for _ in range(N): if grid[pos[0]][pos[1]] == '.': grid[pos[0]][pos[1]] = '#' direction = rotate_clockwise(direction) else: grid[pos[0]][pos[1]] = '.' direction = rotate_counterclockwise(direction) pos = move_forward(pos, direction) # Toroidal grid handling pos = (pos[0] % H, pos[1] % W) return grid def print_grid(grid |
[{"input": "3 4 5\n", "output": ".#..\n##..\n....\n", "testtype": "stdin"}, {"input": "2 2 1000\n", "output": "..\n..\n", "testtype": "stdin"}, {"input": "10 10 10\n", "output": "##........\n##........\n..........\n..........\n..........\n..........\n..........\n..........\n..........\n#........#\n", "testtype": "stdin"}] |
| wenxinyiyan | ```python import sys def get_next_position(cur_pos, cur_dir, H, W): # Define the directions: 0=up, 1=right, 2=down, 3=left dx = [0, 1, 0, -1] dy = [-1, 0, 1, 0] # Calculate the next position x, y = cur_pos nx, ny = (x + dx[cur_dir]) % H, (y + dy[cur_dir]) % W if nx == 0: nx = H if ny == 0: ny = W return (nx, ny) def get_next_direction(cur_dir, is_white): # Rotate 90 degrees clockwise if white, counterclockwise if black if is_white: return (cur_dir + 1) % 4 else: return (cur_dir - 1) % 4 def print_grid(grid, H, W): for i in range(H): for j in range(W): print(grid[i][j], end='') print() # Read input values H, W, N = map(int, sys.stdin.readline().split()) # Initialize the grid and Takahashi's position and direction grid = [['.' for _ in range(W)] for _ in range(H)] pos = (1, 1) dir = 0 # 0: up, 1: right, 2: down, 3: left # Perform N operations for _ in range(N): # Get the current cell color is_white = grid[pos[0]-1][pos[1]-1] == '.' # Repaint the cell and update the direction grid[pos[0]-1][pos[1]-1] = '#' if is_white else '.' dir = get_next_direction(dir, is_white) # Move to the next position pos = get_next_position(pos, dir, H, W) # Print the final grid print_grid(grid, H, W) ``` |
[{"input": "3 4 5\n", "output": ".#..\n##..\n....\n", "testtype": "stdin"}, {"input": "2 2 1000\n", "output": "..\n..\n", "testtype": "stdin"}, {"input": "10 10 10\n", "output": "##........\n##........\n..........\n..........\n..........\n..........\n..........\n..........\n..........\n#........#\n", "testtype": "stdin"}] |
| zhipu | ```python def main(): import sys input = sys.stdin.read data = input().split() H, W, N = int(data[0]), int(data[1]), int(data[2]) # Initialize the grid with all cells white grid = [['.' for _ in range(W)] for _ in range(H)] # Directions correspond to [up, right, down, left] directions = [(-1, 0), (0, 1), (1, 0), (0, -1)] current_direction = 0 # Start facing up # Starting position x, y = 0, 0 for _ in range(N): if grid[x][y] == '.': grid[x][y] = '#' current_direction = (current_direction + 1) % 4 else: grid[x][y] = '.' current_direction = (current_direction - 1) % 4 # Move forward in the current direction dx, dy = directions[current_direction] x = (x + dx) % H y = (y + dy) % W # Output the final grid for row in grid: print(''.join(row)) if __name__ == "__main__": main() ``` |
[{"input": "3 4 5\n", "output": ".#..\n##..\n....\n", "testtype": "stdin"}, {"input": "2 2 1000\n", "output": "..\n..\n", "testtype": "stdin"}, {"input": "10 10 10\n", "output": "##........\n##........\n..........\n..........\n..........\n..........\n..........\n..........\n..........\n#........#\n", "testtype": "stdin"}] |
| deepseek-v3 | ```python # YOUR CODE HERE H, W, N = map(int, input().split()) # Initialize the grid grid = [[False for _ in range(W)] for _ in range(H)] # Takahashi's initial position and direction # Directions: 0 = up, 1 = right, 2 = down, 3 = left x, y = 0, 0 direction = 0 # Define the movement deltas for each direction delta = [(-1, 0), (0, 1), (1, 0), (0, -1)] for _ in range(N): # Check current cell color if grid[x][y]: # If black, repaint to white, rotate counterclockwise grid[x][y] = False direction = (direction - 1) % 4 else: # If white, repaint to black, rotate clockwise grid[x][y] = True direction = (direction + 1) % 4 # Move forward dx, dy = delta[direction] x = (x + dx) % H y = (y + dy) % W # Print the grid for row in grid: line = ''.join(['#' if cell else '.' for cell in row]) print(line) ``` |
[{"input": "3 4 5\n", "output": ".#..\n##..\n....\n", "testtype": "stdin"}, {"input": "2 2 1000\n", "output": "..\n..\n", "testtype": "stdin"}, {"input": "10 10 10\n", "output": "##........\n##........\n..........\n..........\n..........\n..........\n..........\n..........\n..........\n#........#\n", "testtype": "stdin"}] |