| Task: | Robotti |
| Sender: | OorigamiK |
| Submission time: | 2026-01-17 13:30:49 +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.00 s | details |
Code
#include <bits/stdc++.h>
using namespace std;
struct Dir{
int x;
int y;
};
struct Pos{
int x;
int y;
};
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<<"pos: "<<pos.x+1<<" "<<pos.y+1<<"\n";
dir = chooseDir(grid[pos.y][pos.x], dir);
if (grid[pos.y][pos.x]=='/'){
grid[pos.y][pos.x]='\\';
}
if (grid[pos.y][pos.x]=='\\'){
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<<"\n";
return step+1;
}
pos={pos.x+dir.x, pos.y+dir.y};
step++;
}
return 1;
}Test details
Test 1 (public)
Verdict: RUNTIME ERROR
| input |
|---|
| 3 ./\ \./ \/. |
| correct output |
|---|
| 13 |
| user output |
|---|
| 12 |
Test 2
Verdict: RUNTIME ERROR
| input |
|---|
| 1 . |
| correct output |
|---|
| 1 |
| user output |
|---|
| 0 |
Test 3
Verdict: RUNTIME ERROR
| input |
|---|
| 5 ./\/\ ..... ..... ..... ... |
| correct output |
|---|
| 25 |
| user output |
|---|
| 24 |
Test 4
Verdict: RUNTIME ERROR
| input |
|---|
| 5 \\/\\ /\/\/ \\/\\ /\/\/ ... |
| correct output |
|---|
| 37 |
| user output |
|---|
| 17 |
Test 5
Verdict: RUNTIME ERROR
| input |
|---|
| 20 \\/\/\/\\./\\.\/\/\. /\\\\\\/\\\\\\\\\\\. \\\\\\\\\\\\\\\\\\\\ /\\\\\\\\\\\\\.\\\\\ ... |
| correct output |
|---|
| 2519 |
| user output |
|---|
| 84 |
Test 6
Verdict: RUNTIME ERROR
| input |
|---|
| 20 \\.................. .\\..............\\. ..\\............\\.. ...\\..........\\... ... |
| correct output |
|---|
| 917489 |
| user output |
|---|
| 89 |
