Submission details
Task:Robotti
Sender:Nyno
Submission time:2026-01-17 14:18:54 +0200
Language:C++ (C++17)
Status:READY
Result:0
Feedback
groupverdictscore
#10
Test results
testverdicttime
#1ACCEPTED0.00 sdetails
#20.00 sdetails
#30.00 sdetails
#40.00 sdetails
#50.00 sdetails
#60.00 sdetails

Code

#include <bits/stdc++.h>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>

using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    int l=1;
    cin >> n;
    int x=0,y=0,dx=0,dy=1;
    vector<string> v;
    for (int i = 0; i < n; i++)
    {
        string s;
        cin >> s;
        v.push_back(s);
    }
    int nx = 0; // (nx >= 0 && nx < n)&&(ny >= 0 && ny < n)
    int ny = 0;
    while(l < 13) { 
        nx = x+dx;
        ny = y+dy;


        if (v[ny][nx] == '/') {
            if (dx == 1) {
                dy = -1;
                dx = 0;
            }else if (dx == -1){
                dy = 1;
                dx = 0;
            }else if (dy == 1){
                dy = 0;
                dx = -1;
            }else if (dy == -1){
                dy = 0;
                dx = 1;
            }
        }

        if (v[ny][nx] == '\\') {

            if (dx == 1) {
                dy = +1;
                dx = 0;
            }else if (dx == -1){
                dy = -1;
                dx = 0;
            }else if (dy == 1){
                dy = 0;
                dx = 1;
            }else if (dy == -1){
                dy = 0;
                dx = -1;
            }
        }
        l++;

        if (ny+dy < 0 || ny+dy >= n || nx+dx < 0 || nx+dx >= n) {
            break;
        }


        v[y][x] = (v[y][x] == '/') ? '\\' : (v[y][x] == '\\') ? '/' : '.';

        x = nx;
        y = ny;


    }


    cout << l;
    

    return 0;
}

Test details

Test 1 (public)

Verdict: ACCEPTED

input
3
./\
\./
\/.

correct output
13

user output
13

Test 2

Verdict:

input
1
.

correct output
1

user output
(empty)

Test 3

Verdict:

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

correct output
25

user output
13

Feedback: Incorrect character on line 1 col 1: expected "25", got "13"

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
13

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