| Task: | Robotti |
| Sender: | Wiita |
| Submission time: | 2026-01-17 13:44:11 +0200 |
| Language: | C++ (C++17) |
| Status: | READY |
| Result: | 100 |
| group | verdict | score |
|---|---|---|
| #1 | ACCEPTED | 100 |
| test | verdict | time | |
|---|---|---|---|
| #1 | ACCEPTED | 0.00 s | details |
| #2 | ACCEPTED | 0.00 s | details |
| #3 | ACCEPTED | 0.00 s | details |
| #4 | ACCEPTED | 0.00 s | details |
| #5 | ACCEPTED | 0.00 s | details |
| #6 | ACCEPTED | 0.01 s | details |
Code
#include <iostream>
#include <bits/stdc++.h>
#include <algorithm>
#include <vector>
using namespace std;
long long n;
int main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);
cin >> n;
vector<string> grid(n);
for (int i = 0; i < n; i++)
{
cin >> grid[i];
}
long long x = 0, y = -1;
long long dx = 0, dy = 1;
long long steps = 0;
while (true)
{
//cout << dy << dx << " ";
//cout << " " << y << x << " ";
x += dx;
y += dy;
if (x < 0 || x >= n || y < 0 || y >= n) break;
steps++;
if (grid[y][x] == '\\')
{
if (dy == 1) {dy = 0; dx = 1;}
else if (dy == -1) {dy = 0; dx = -1;}
else if (dx == 1) {dy = 1; dx = 0;}
else if (dx == -1) {dy = -1; dx = 0;}
grid[y][x] = '/';
}
else if (grid[y][x] == '/')
{
if (dy == 1) {dy = 0; dx = -1;}
else if (dy == -1) {dy = 0; dx = 1;}
else if (dx == 1) {dy = -1; dx = 0;}
else if (dx == -1) {dy = 1; dx = 0;}
grid[y][x] = '\\';
}
}
cout << steps;
return 0;
}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 |
