Submission details
Task:Robotti
Sender:OorigamiK
Submission time:2026-01-17 13:45:17 +0200
Language:C++ (C++20)
Status:READY
Result:0
Feedback
groupverdictscore
#10
Test results
testverdicttime
#10.00 sdetails
#20.00 sdetails
#30.00 sdetails
#40.00 sdetails
#50.00 sdetails
#60.01 sdetails

Compiler report

input/code.cpp: In function 'void printgrid(std::vector<std::__cxx11::basic_string<char> >, Pos)':
input/code.cpp:16:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::__cxx11::basic_string<char> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   16 |     for (int i=0;i<grid.size();i++){
      |                  ~^~~~~~~~~~~~
input/code.cpp:17:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::__cxx11::basic_string<char> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   17 |         for (int j=0;j<grid.size();j++){
      |                      ~^~~~~~~~~~~~
input/code.cpp:18:32: warning: comparison of integer expressions of different signedness: 'std::vector<std::__cxx11::basic_string<char> >::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   18 |             if (grid.size()-1-i==pos.y && j==pos.x){
      |                 ~~~~~~~~~~~~~~~^~~~~~~

Code

#include <bits/stdc++.h>

using namespace std;

struct Dir{
    int x;
    int y;
};

struct Pos{
    int x;
    int y;
};

void printgrid(vector<string> grid, Pos pos){
    for (int i=0;i<grid.size();i++){
        for (int j=0;j<grid.size();j++){
            if (grid.size()-1-i==pos.y && j==pos.x){
                cout<<"X";
            }
            else{
                cout<<grid[grid.size()-1-i][j];
            }
        }
        cout<<"\n";
    }
    cout<<"\n";
}


Dir chooseDir(char obstacle, Dir dir){
    if (obstacle=='.'){
        return dir;
    }
    if (obstacle=='/'){
        if (dir.x==1){
            return {0, 1};
        }
        if (dir.x==-1){
            return {0, -1};
        }
        if (dir.y==1){
            return {1, 0};
        }
        if (dir.y==-1){
            return {-1, 0};
        }
    }
    if (obstacle=='\\'){
        if (dir.x==-1){
            return {0, 1};
        }
        if (dir.x==1){
            return {0, -1};
        }
        if (dir.y==-1){
            return {1, 0};
        }
        if (dir.y==1){
            return {-1, 0};
        }
    }
    return {0 ,0};
}
int main(){
    int n;
    cin>>n;
    vector<string> grid(n);
    for (int i=0;i<n;i++){
        string s;
        cin>>s;
        grid[n-1-i]=s;
    }

    Pos pos={0, n-1};
    Dir dir={0, -1};

    int step=0;
    while (true){
        //cout<<step<<"\n";
        //cout<<"pos: "<<pos.x+1<<" "<<pos.y+1<<"\n";
        //printgrid(grid, pos);
        dir = chooseDir(grid[pos.y][pos.x], dir);
        if (grid[pos.y][pos.x]=='/'){
            //cout<<"hi"<<char(92)<<"\n";
            grid[pos.y][pos.x]=char(92);
            //cout<<grid[pos.y][pos.x]<<"\n";
        }
        else if (grid[pos.y][pos.x]==char(92)){
            grid[pos.y][pos.x]='/';
        }
        //cout<<"dir: "<<dir.x<<" "<<dir.y<<" "<<grid[pos.y][pos.x]<<"\n";

        if (pos.x+dir.x>n-1 || pos.x+dir.x<0 || pos.y+dir.y>n-1 || pos.y+dir.y<0){
            cout<<step+1<<"\n";
            return step+1;
        }
        pos={pos.x+dir.x, pos.y+dir.y};
        step++;

    }


    return 1;
}

Test details

Test 1 (public)

Verdict:

input
3
./\
\./
\/.

correct output
13

user output
13

Test 2

Verdict:

input
1
.

correct output
1

user output
1

Test 3

Verdict:

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

correct output
25

user output
25

Test 4

Verdict:

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

correct output
37

user output
37

Test 5

Verdict:

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

correct output
2519

user output
2519

Test 6

Verdict:

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

correct output
917489

user output
917489