Submission details
Task:Robotti
Sender:Tmotomaster
Submission time:2026-01-17 13:18:33 +0200
Language:C++ (C++20)
Status:READY
Result:0
Feedback
groupverdictscore
#10
Test results
testverdicttime
#1ACCEPTED0.00 sdetails
#2ACCEPTED0.00 sdetails
#3ACCEPTED0.00 sdetails
#40.00 sdetails
#50.00 sdetails
#60.00 sdetails

Code

#include <bits/stdc++.h>
using namespace std;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    int n;
    cin >> n;

    string* world = new string[n];
    for (int i = 0; i < n; i++) {
        string row;
        cin >> row;
        world[i] = row;
    }

    int posX = 0;
    int posY = 0;
    int dir = 3;

    int count = 0;
    while (posX >= 0 && posX < n && posY >= 0 && posY < n) {
        count++;
        if (dir == 0) {
            posX++;
            if (posX >= n) break;
            if (world[posY][posX] == '/') {
                dir = 1;
                world[posY][posX] = '\\';
            } else if (world[posY][posX] == '\\') {
                dir = 3;
                world[posY][posX] = '/';
            }
        } else if (dir == 1) {
            posY--;
            if (posY < 0) break;
            if (world[posY][posX] == '/') {
                dir = 0;
                world[posY][posX] = '\\';
            } else if (world[posY][posX] == '\\') {
                dir = 2;
                world[posY][posX] = '/';
            }
        } else if (dir == 2) {
            posX--;
            if (posX < 0) break;
            if (world[posY][posX] == '/') {
                dir = 3;
                world[posY][posX] = '\\';
            } else if (world[posY][posX] == '\\') {
                dir = 1;
                world[posY][posX] = '/';
            }
        } else {
            posY++;
            if (posY >= n) break;
            // cout << world[posY][posX] << endl;
            if (world[posY][posX] == '/') {
                dir = 2;
                world[posY][posX] = '\\';
            } else if (world[posY][posX] == '\\') {
                dir = 0;
                world[posY][posX] = '/';
            }
        }
    }

    cout << count;
    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:

input
5
\\/\\
/\/\/
\\/\\
/\/\/
...

correct output
37

user output
2

Feedback: Incorrect character on line 1 col 1: expected "37", got "2"

Test 5

Verdict:

input
20
\\/\/\/\\./\\.\/\/\.
/\\\\\\/\\\\\\\\\\\.
\\\\\\\\\\\\\\\\\\\\
/\\\\\\\\\\\\\.\\\\\
...

correct output
2519

user output
2

Feedback: Incorrect character on line 1 col 2: expected "2519", got "2"

Test 6

Verdict:

input
20
\\..................
.\\..............\\.
..\\............\\..
...\\..........\\...
...

correct output
917489

user output
19

Feedback: Incorrect character on line 1 col 1: expected "917489", got "19"