Task: | Nautilus |
Sender: | MojoLake |
Submission time: | 2023-04-18 13:06:38 +0300 |
Language: | C++ (C++17) |
Status: | READY |
Result: | 66 |
group | verdict | score |
---|---|---|
#1 | ACCEPTED | 29 |
#2 | ACCEPTED | 37 |
#3 | RUNTIME ERROR | 0 |
test | verdict | time | group | |
---|---|---|---|---|
#1 | ACCEPTED | 0.00 s | 2, 3 | details |
#2 | ACCEPTED | 0.02 s | 1, 2, 3 | details |
#3 | ACCEPTED | 0.01 s | 1, 2, 3 | details |
#4 | ACCEPTED | 0.01 s | 1, 2, 3 | details |
#5 | ACCEPTED | 0.01 s | 1, 2, 3 | details |
#6 | ACCEPTED | 0.01 s | 1, 2, 3 | details |
#7 | ACCEPTED | 0.00 s | 1, 2, 3 | details |
#8 | ACCEPTED | 0.02 s | 2, 3 | details |
#9 | ACCEPTED | 0.01 s | 2, 3 | details |
#10 | ACCEPTED | 0.01 s | 2, 3 | details |
#11 | ACCEPTED | 0.01 s | 2, 3 | details |
#12 | ACCEPTED | 0.00 s | 2, 3 | details |
#13 | ACCEPTED | 0.03 s | 2, 3 | details |
#14 | ACCEPTED | 0.04 s | 2, 3 | details |
#15 | ACCEPTED | 0.03 s | 2, 3 | details |
#16 | ACCEPTED | 0.01 s | 2, 3 | details |
#17 | ACCEPTED | 0.00 s | 2, 3 | details |
#18 | ACCEPTED | 0.03 s | 2, 3 | details |
#19 | ACCEPTED | 0.04 s | 2, 3 | details |
#20 | ACCEPTED | 0.01 s | 2, 3 | details |
#21 | ACCEPTED | 0.01 s | 2, 3 | details |
#22 | ACCEPTED | 0.00 s | 2, 3 | details |
#23 | RUNTIME ERROR | 0.01 s | 3 | details |
#24 | RUNTIME ERROR | 0.03 s | 3 | details |
#25 | RUNTIME ERROR | 0.01 s | 3 | details |
#26 | RUNTIME ERROR | 0.01 s | 3 | details |
#27 | WRONG ANSWER | 0.01 s | 3 | details |
#28 | RUNTIME ERROR | 0.01 s | 3 | details |
#29 | RUNTIME ERROR | 0.01 s | 3 | details |
#30 | RUNTIME ERROR | 0.06 s | 3 | details |
#31 | RUNTIME ERROR | 0.01 s | 3 | details |
#32 | WRONG ANSWER | 0.01 s | 3 | details |
#33 | RUNTIME ERROR | 0.01 s | 3 | details |
#34 | RUNTIME ERROR | 0.02 s | 3 | details |
#35 | RUNTIME ERROR | 0.04 s | 3 | details |
#36 | RUNTIME ERROR | 0.04 s | 3 | details |
#37 | WRONG ANSWER | 0.01 s | 3 | details |
Code
#include <bits/stdc++.h> #define debug(x) cout << #x << ": " << x << "\n" #define all(x) x.begin(), x.end() using namespace std; using ll = long long; const int N = 101; const int M = 101; const int inf = 1e9; const ll LLinf = 1e16; bool grid[N][N]; bool ready[N][N][M]; bool pos[N][N]; string s; int R, C, m; int dy[4] = {1, -1, 0, 0}; int dx[4] = {0, 0, 1, -1}; map<char, int> c_to_dir; bool ok(int y, int x){ return y >= 0 && y < R && x >= 0 && x < C; } void dfs(int y, int x, int ind){ if(ind == m){ pos[y][x] = 1; ready[y][x][ind] = 1; return; } if(s[ind] == '?'){ for(int i = 0; i < 4; ++i){ int ny = y + dy[i]; int nx = x + dx[i]; if(!ok(ny, nx) || grid[ny][nx] || ready[ny][nx][ind+1])continue; dfs(ny, nx, ind+1); } }else{ int dir = c_to_dir[s[ind]]; int ny = y + dy[dir]; int nx = x + dx[dir]; if(!ok(ny, nx) || grid[ny][nx] || ready[ny][nx][ind+1])return; dfs(ny, nx, ind + 1); } ready[y][x][ind] = 1; } int main(){ cin.tie(0)->sync_with_stdio(0); c_to_dir['S'] = 0; c_to_dir['N'] = 1; c_to_dir['E'] = 2; c_to_dir['W'] = 3; cin >> R >> C >> m; for(int i = 0; i < R; ++i){ for(int j = 0; j < C; ++j){ char c; cin >> c; grid[i][j] = c == '#'; } } cin >> s; for(int i = 0; i < R; ++i){ for(int j = 0; j < C; ++j){ if(grid[i][j])continue; dfs(i, j, 0); } } int ans = 0; for(int i = 0; i < R; ++i){ for(int j = 0; j < C; ++j){ ans += (int)pos[i][j]; } } cout << ans << "\n"; }
Test details
Test 1
Group: 2, 3
Verdict: ACCEPTED
input |
---|
5 9 7 ...##.... ..#.##..# ..#....## .##...#.. ... |
correct output |
---|
22 |
user output |
---|
22 |
Test 2
Group: 1, 2, 3
Verdict: ACCEPTED
input |
---|
100 100 100 ................................. |
correct output |
---|
8272 |
user output |
---|
8272 |
Test 3
Group: 1, 2, 3
Verdict: ACCEPTED
input |
---|
100 100 100 .#...#.#..#.....#.........#...... |
correct output |
---|
5 |
user output |
---|
5 |
Test 4
Group: 1, 2, 3
Verdict: ACCEPTED
input |
---|
100 100 100 .#...##...#...##....##.#.##..#... |
correct output |
---|
1 |
user output |
---|
1 |
Test 5
Group: 1, 2, 3
Verdict: ACCEPTED
input |
---|
100 100 100 ..#.#.#..###.#.#.##..########.... |
correct output |
---|
1 |
user output |
---|
1 |
Test 6
Group: 1, 2, 3
Verdict: ACCEPTED
input |
---|
100 100 100 .#.#.###########..#.###.######... |
correct output |
---|
1 |
user output |
---|
1 |
Test 7
Group: 1, 2, 3
Verdict: ACCEPTED
input |
---|
100 100 100 ##############################... |
correct output |
---|
1 |
user output |
---|
1 |
Test 8
Group: 2, 3
Verdict: ACCEPTED
input |
---|
100 100 100 ................................. |
correct output |
---|
9503 |
user output |
---|
9503 |
Test 9
Group: 2, 3
Verdict: ACCEPTED
input |
---|
100 100 100 #..#.##..#....##...#.##.##..#.... |
correct output |
---|
495 |
user output |
---|
495 |
Test 10
Group: 2, 3
Verdict: ACCEPTED
input |
---|
100 100 100 #.#...######.#####.#.##...#.##... |
correct output |
---|
51 |
user output |
---|
51 |
Test 11
Group: 2, 3
Verdict: ACCEPTED
input |
---|
100 100 100 .#.#.###########..#.###.######... |
correct output |
---|
34 |
user output |
---|
34 |
Test 12
Group: 2, 3
Verdict: ACCEPTED
input |
---|
100 100 100 ##############################... |
correct output |
---|
19 |
user output |
---|
19 |
Test 13
Group: 2, 3
Verdict: ACCEPTED
input |
---|
100 100 100 ................................. |
correct output |
---|
9801 |
user output |
---|
9801 |
Test 14
Group: 2, 3
Verdict: ACCEPTED
input |
---|
100 100 100 ..............#.................. |
correct output |
---|
7479 |
user output |
---|
7479 |
Test 15
Group: 2, 3
Verdict: ACCEPTED
input |
---|
100 100 100 #.#.........###.#..#.#..####.#... |
correct output |
---|
5328 |
user output |
---|
5328 |
Test 16
Group: 2, 3
Verdict: ACCEPTED
input |
---|
100 100 100 .#.#.###########..#.###.######... |
correct output |
---|
127 |
user output |
---|
127 |
Test 17
Group: 2, 3
Verdict: ACCEPTED
input |
---|
100 100 100 ##############################... |
correct output |
---|
19 |
user output |
---|
19 |
Test 18
Group: 2, 3
Verdict: ACCEPTED
input |
---|
100 100 100 ................................. |
correct output |
---|
10000 |
user output |
---|
10000 |
Test 19
Group: 2, 3
Verdict: ACCEPTED
input |
---|
100 100 100 ..............#.................. |
correct output |
---|
8047 |
user output |
---|
8047 |
Test 20
Group: 2, 3
Verdict: ACCEPTED
input |
---|
100 100 100 #.#...######.#####.#.##...#.##... |
correct output |
---|
3500 |
user output |
---|
3500 |
Test 21
Group: 2, 3
Verdict: ACCEPTED
input |
---|
100 100 100 .#.#.###########..#.###.######... |
correct output |
---|
1228 |
user output |
---|
1228 |
Test 22
Group: 2, 3
Verdict: ACCEPTED
input |
---|
100 100 100 ##############################... |
correct output |
---|
43 |
user output |
---|
43 |
Test 23
Group: 3
Verdict: RUNTIME ERROR
input |
---|
500 500 5000 ................................. |
correct output |
---|
249493 |
user output |
---|
(empty) |
Test 24
Group: 3
Verdict: RUNTIME ERROR
input |
---|
500 500 5000 #..#.##..#....##...#.##.##..#.... |
correct output |
---|
222 |
user output |
---|
(empty) |
Test 25
Group: 3
Verdict: RUNTIME ERROR
input |
---|
500 500 5000 .#####....####..###...####.#.#... |
correct output |
---|
1268 |
user output |
---|
(empty) |
Test 26
Group: 3
Verdict: RUNTIME ERROR
input |
---|
500 500 5000 #.#####.##..#####.####..######... |
correct output |
---|
805 |
user output |
---|
(empty) |
Test 27
Group: 3
Verdict: WRONG ANSWER
input |
---|
500 500 5000 ##############################... |
correct output |
---|
349 |
user output |
---|
0 |
Test 28
Group: 3
Verdict: RUNTIME ERROR
input |
---|
500 500 5000 ................................. |
correct output |
---|
249999 |
user output |
---|
(empty) |
Test 29
Group: 3
Verdict: RUNTIME ERROR
input |
---|
500 500 5000 ..............#.................. |
correct output |
---|
197917 |
user output |
---|
(empty) |
Test 30
Group: 3
Verdict: RUNTIME ERROR
input |
---|
500 500 5000 #.#.........###.#..#.#..####.#... |
correct output |
---|
79550 |
user output |
---|
(empty) |
Test 31
Group: 3
Verdict: RUNTIME ERROR
input |
---|
500 500 5000 #.#####.##..#####.####..######... |
correct output |
---|
1221 |
user output |
---|
(empty) |
Test 32
Group: 3
Verdict: WRONG ANSWER
input |
---|
500 500 5000 ##############################... |
correct output |
---|
1414 |
user output |
---|
0 |
Test 33
Group: 3
Verdict: RUNTIME ERROR
input |
---|
500 500 5000 ................................. |
correct output |
---|
250000 |
user output |
---|
(empty) |
Test 34
Group: 3
Verdict: RUNTIME ERROR
input |
---|
500 500 5000 ..............#.................. |
correct output |
---|
199752 |
user output |
---|
(empty) |
Test 35
Group: 3
Verdict: RUNTIME ERROR
input |
---|
500 500 5000 .#####....####..###...####.#.#... |
correct output |
---|
87691 |
user output |
---|
(empty) |
Test 36
Group: 3
Verdict: RUNTIME ERROR
input |
---|
500 500 5000 #.#####.##..#####.####..######... |
correct output |
---|
30998 |
user output |
---|
(empty) |
Test 37
Group: 3
Verdict: WRONG ANSWER
input |
---|
500 500 5000 ##############################... |
correct output |
---|
1440 |
user output |
---|
0 |