| Task: | Robotti |
| Sender: | Karjalanp11rakka |
| Submission time: | 2026-01-17 13:27:17 +0200 |
| Language: | C++ (C++20) |
| Status: | READY |
| Result: | 100 |
| group | verdict | score |
|---|---|---|
| #1 | ACCEPTED | 100 |
| test | verdict | time | |
|---|---|---|---|
| #1 | ACCEPTED | 0.00 s | details |
| #2 | ACCEPTED | 0.00 s | details |
| #3 | ACCEPTED | 0.00 s | details |
| #4 | ACCEPTED | 0.00 s | details |
| #5 | ACCEPTED | 0.00 s | details |
| #6 | ACCEPTED | 0.01 s | details |
Code
#include <bits/stdc++.h>
using namespace std;
int n;
char t[20][20];
int s {};
void search(int x, int y, int d)
{
++s;
if(x == n || x == -1 || y == n || y == -1) return;
if(t[x][y] == '.')
{
if(d == 0) search(x, y + 1, d);
else if(d == 1) search(x, y - 1, d);
else if(d == 2) search(x + 1, y, d);
else search(x - 1, y, d);
}
else if(t[x][y] == '/')
{
t[x][y] = '\\';
if(d == 0) search(x - 1, y, 3);
if(d == 1) search(x + 1, y, 2);
if(d == 2) search(x, y - 1, 1);
if(d == 3) search(x, y + 1, 0);
}
else
{
t[x][y] = '/';
if(d == 1) search(x - 1, y, 3);
if(d == 0) search(x + 1, y, 2);
if(d == 3) search(x, y - 1, 1);
if(d == 2) search(x, y + 1, 0);
}
}
int main()
{
cin >> n;
for(int i {}; i < n; ++i)
for(int j {}; j < n; ++j)
cin >> t[j][i];
search(0, 0, 0);
cout << s - 1;
}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 |
