| Task: | Robotti |
| Sender: | Toitsu |
| Submission time: | 2026-01-17 13:13:50 +0200 |
| Language: | Python3 (PyPy3) |
| Status: | READY |
| Result: | 100 |
| group | verdict | score |
|---|---|---|
| #1 | ACCEPTED | 100 |
| test | verdict | time | |
|---|---|---|---|
| #1 | ACCEPTED | 0.04 s | details |
| #2 | ACCEPTED | 0.04 s | details |
| #3 | ACCEPTED | 0.04 s | details |
| #4 | ACCEPTED | 0.04 s | details |
| #5 | ACCEPTED | 0.05 s | details |
| #6 | ACCEPTED | 0.09 s | details |
Code
grid_size = int(input())
grid = []
for x in range(grid_size):
grid.append(list(input()))
robot_x = 0
robot_y = 0
step_count = 1
direction = "down"
while True:
char = grid[robot_y][robot_x]
if char == ".":
if direction == "down":
robot_y = robot_y + 1
elif direction == "up":
robot_y = robot_y - 1
elif direction == "right":
robot_x = robot_x + 1
elif direction == "left":
robot_x = robot_x - 1
elif char == "/":
# flip the char
grid[robot_y][robot_x] = "\\"
if direction == "down":
robot_x = robot_x - 1
direction = "left"
elif direction == "up":
robot_x = robot_x + 1
direction = "right"
elif direction == "right":
robot_y = robot_y - 1
direction = "up"
elif direction == "left":
robot_y = robot_y + 1
direction = "down"
elif char == "\\":
# flip the char
grid[robot_y][robot_x] = "/"
if direction == "down":
robot_x = robot_x + 1
direction = "right"
elif direction == "up":
robot_x = robot_x - 1
direction = "left"
elif direction == "right":
robot_y = robot_y + 1
direction = "down"
elif direction == "left":
robot_y = robot_y - 1
direction = "up"
if robot_x >= grid_size or robot_x < 0 or robot_y >= grid_size or robot_y < 0:
break
step_count = step_count + 1
print(step_count)Test details
Test 1 (public)
Verdict: ACCEPTED
| input |
|---|
| 3 ./\ \./ \/. |
| correct output |
|---|
| 13 |
| user output |
|---|
| 13 |
Test 2
Verdict: ACCEPTED
| input |
|---|
| 1 . |
| correct output |
|---|
| 1 |
| user output |
|---|
| 1 |
Test 3
Verdict: ACCEPTED
| input |
|---|
| 5 ./\/\ ..... ..... ..... ... |
| correct output |
|---|
| 25 |
| user output |
|---|
| 25 |
Test 4
Verdict: ACCEPTED
| input |
|---|
| 5 \\/\\ /\/\/ \\/\\ /\/\/ ... |
| correct output |
|---|
| 37 |
| user output |
|---|
| 37 |
Test 5
Verdict: ACCEPTED
| input |
|---|
| 20 \\/\/\/\\./\\.\/\/\. /\\\\\\/\\\\\\\\\\\. \\\\\\\\\\\\\\\\\\\\ /\\\\\\\\\\\\\.\\\\\ ... |
| correct output |
|---|
| 2519 |
| user output |
|---|
| 2519 |
Test 6
Verdict: ACCEPTED
| input |
|---|
| 20 \\.................. .\\..............\\. ..\\............\\.. ...\\..........\\... ... |
| correct output |
|---|
| 917489 |
| user output |
|---|
| 917489 |
