Submission details
Task:Robotti
Sender:Verlet
Submission time:2026-01-17 13:20:05 +0200
Language:C++ (C++20)
Status:READY
Result:100
Feedback
groupverdictscore
#1ACCEPTED100
Test results
testverdicttime
#1ACCEPTED0.00 sdetails
#2ACCEPTED0.00 sdetails
#3ACCEPTED0.00 sdetails
#4ACCEPTED0.00 sdetails
#5ACCEPTED0.00 sdetails
#6ACCEPTED0.01 sdetails

Code

#include <iostream>
#include <string>

using namespace std;

struct v2
{
    int x;
    int y;
};

int main()
{
    int n; cin >> n;

    string m[n];
    for (string & s : m)
        cin >> s;
    
    // for (string & s : m)
    //    cout << s << endl;

    int c = 0;
    v2 r = {0, 0};
    v2 d = {0, 1};
    while (true)
    {
        // for (int y = 0; y < n; y++)
        // {
        //     for (int x = 0; x < n; x++)
        //     {
        //         if (x == r.x && y == r.y)
        //             cout << 'X' << " ";
        //         else cout << m[y][x] << " ";
        //     }
        //     cout << endl;
        // }
        // cout << endl;

        if (r.x <  0 || r.x >= n || r.y < 0 || r.y >= n)
            break;
        
        if (m[r.y][r.x] == '/')
        {
            m[r.y][r.x] = '\\';

            if (d.x == 1)
            {
                d.x = 0; d.y = -1;
            }
            else if (d.x == -1)
            {
                d.x = 0; d.y = 1;
            }
            else if (d.y == 1)
            {
                d.y = 0; d.x = -1;
            }
            else if (d.y == -1)
            {
                d.y = 0; d.x = 1;
            }
        }
        else if (m[r.y][r.x] == '\\')
        {
            m[r.y][r.x] = '/';

            if (d.x == 1)
            {
                d.x = 0; d.y = 1;
            }
            else if (d.x == -1)
            {
                d.x = 0; d.y = -1;
            }
            else if (d.y == 1)
            {
                d.y = 0; d.x = 1;
            }
            else if (d.y == -1)
            {
                d.y = 0; d.x = -1;
            }
        }

        r.x += d.x;
        r.y += d.y;

        c++;
    }

    cout << c << endl;
}

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