Submission details
Task:Robotti
Sender:alli
Submission time:2026-01-17 14:07:03 +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.01 sdetails

Code

#include<bits/stdc++.h>
 
typedef long long ll;
using namespace std;
 
char c[21][21];
int n, k = 0;
int d = -2;
 
int main(){
    cin >> n;
    for (int i = 1; i <= n; i++){
        for (int j = 1; j <= n; j++){
            cin >> c[i][j];
        }
    }
    int x = 1, y = 1;
    while (true){
        if (x == n && y == n+1) break;
        //cout << x << " " << y << " " << d << "\n";
        k++;
        if (c[y][x] == '\\'){
            c[y][x] = '/';
            if (d == -2){
                d = 1;
                x++;
            }
            else if (d == 2){
                d = -1;
                x--;
            }
            else if (d == 1){
                d = -2;
                y++;
            }
            else if (d == -1){
                d = 2;
                y--;
            }
        }
        else if (c[y][x] == '/'){
            c[y][x] = '\\';
            if (d == -2){
                d = -1;
                x--;
            }
            else if (d == 2){
                d = 1;
                x++;
            }
            else if (d == 1){
                d = 2;
                y--;
            }
            else if (d == -1){
                d = -2;
                y++;
            }
        }
        else {
            if (d == -2) y++;
            else if (d == 2) y--;
            else if (d == 1) x++;
            else if (d == -1) x--;
        }
    }
    //cout << x << " " << y << " " << d << "\n";
    cout << k << "\n";
}

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
(empty)

Test 5

Verdict:

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

correct output
2519

user output
(empty)

Test 6

Verdict:

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

correct output
917489

user output
(empty)