| Task: | Robotti |
| Sender: | OorigamiK |
| Submission time: | 2026-01-17 13:45:44 +0200 |
| Language: | C++ (C++20) |
| Status: | READY |
| Result: | 0 |
| group | verdict | score |
|---|---|---|
| #1 | RUNTIME ERROR | 0 |
| test | verdict | time | |
|---|---|---|---|
| #1 | RUNTIME ERROR | 0.00 s | details |
| #2 | RUNTIME ERROR | 0.00 s | details |
| #3 | RUNTIME ERROR | 0.00 s | details |
| #4 | RUNTIME ERROR | 0.00 s | details |
| #5 | RUNTIME ERROR | 0.00 s | details |
| #6 | RUNTIME ERROR | 0.01 s | details |
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 0;
}Test details
Test 1 (public)
Verdict: RUNTIME ERROR
| input |
|---|
| 3 ./\ \./ \/. |
| correct output |
|---|
| 13 |
| user output |
|---|
| 13 |
Test 2
Verdict: RUNTIME ERROR
| input |
|---|
| 1 . |
| correct output |
|---|
| 1 |
| user output |
|---|
| 1 |
Test 3
Verdict: RUNTIME ERROR
| input |
|---|
| 5 ./\/\ ..... ..... ..... ... |
| correct output |
|---|
| 25 |
| user output |
|---|
| 25 |
Test 4
Verdict: RUNTIME ERROR
| input |
|---|
| 5 \\/\\ /\/\/ \\/\\ /\/\/ ... |
| correct output |
|---|
| 37 |
| user output |
|---|
| 37 |
Test 5
Verdict: RUNTIME ERROR
| input |
|---|
| 20 \\/\/\/\\./\\.\/\/\. /\\\\\\/\\\\\\\\\\\. \\\\\\\\\\\\\\\\\\\\ /\\\\\\\\\\\\\.\\\\\ ... |
| correct output |
|---|
| 2519 |
| user output |
|---|
| 2519 |
Test 6
Verdict: RUNTIME ERROR
| input |
|---|
| 20 \\.................. .\\..............\\. ..\\............\\.. ...\\..........\\... ... |
| correct output |
|---|
| 917489 |
| user output |
|---|
| 917489 |
