/*#pragma GCC optimize("O3")
#pragma GCC target ("avx2")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")*/
#include <bits/stdc++.h>
#define file(data) freopen(data".in", "r", stdin); freopen(data".out", "w", stdout);
#define pb push_back
#define all(data) data.begin(), data.end()
#define endl '\n'
#define ll long long
//#define int long long
#define pii pair < int, int >
using namespace std;
const int N = 2e5 + 5;
int n, m, k;
string s;
char c[105][105];
bool used[105][105][105], can[105][105];
void dfs(int x, int y, int pos) {
if(min(x, y) == 0 || y > m || x > n) return;
if(c[x][y] == '#') return;
if(used[x][y][pos]) return;
used[x][y][pos] = 1;
if(pos == k) {
can[x][y] = 1;
return;
}
if(s[pos] == '?') {
dfs(x + 1, y, pos + 1);
dfs(x - 1, y, pos + 1);
dfs(x, y + 1, pos + 1);
dfs(x, y - 1, pos + 1);
}
if(s[pos] == 'W') {
dfs(x, y - 1, pos + 1);
} else if(s[pos] == 'E') {
dfs(x, y + 1, pos + 1);
} else if(s[pos] == 'N') {
dfs(x - 1, y, pos + 1);
} else if(s[pos] == 'S') {
dfs(x + 1, y, pos + 1);
}
}
main() {
//file("pieaters");
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin >> n >> m >> k;
for(int i = 1; i <= n; i++) {
for(int j = 1; j <= m; j++) {
cin >> c[i][j];
}
}
cin >> s;
for(int i = 1; i <= n; i++) {
for(int j = 1; j <= m; j++) {
dfs(i, j, 0);
}
}
int ans = 0;
for(int i = 1; i <= n; i++) {
for(int j = 1; j <= m; j++) {
if(can[i][j]) {
++ans;
}
}
}
cout << ans;
}
Compilation message
nautilus.cpp:50:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
50 | main() {
| ^~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
1356 KB |
Output is correct |
2 |
Correct |
1 ms |
1356 KB |
Output is correct |
3 |
Correct |
1 ms |
1356 KB |
Output is correct |
4 |
Correct |
2 ms |
1356 KB |
Output is correct |
5 |
Correct |
1 ms |
1356 KB |
Output is correct |
6 |
Correct |
1 ms |
332 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
1356 KB |
Output is correct |
2 |
Correct |
1 ms |
1356 KB |
Output is correct |
3 |
Correct |
1 ms |
1356 KB |
Output is correct |
4 |
Correct |
2 ms |
1356 KB |
Output is correct |
5 |
Correct |
1 ms |
1356 KB |
Output is correct |
6 |
Correct |
1 ms |
332 KB |
Output is correct |
7 |
Correct |
10 ms |
1356 KB |
Output is correct |
8 |
Correct |
4 ms |
1368 KB |
Output is correct |
9 |
Correct |
2 ms |
1356 KB |
Output is correct |
10 |
Correct |
1 ms |
1356 KB |
Output is correct |
11 |
Correct |
1 ms |
332 KB |
Output is correct |
12 |
Correct |
18 ms |
1420 KB |
Output is correct |
13 |
Correct |
24 ms |
1424 KB |
Output is correct |
14 |
Correct |
18 ms |
1360 KB |
Output is correct |
15 |
Correct |
2 ms |
1356 KB |
Output is correct |
16 |
Correct |
1 ms |
332 KB |
Output is correct |
17 |
Correct |
23 ms |
1356 KB |
Output is correct |
18 |
Correct |
26 ms |
1400 KB |
Output is correct |
19 |
Correct |
10 ms |
1356 KB |
Output is correct |
20 |
Correct |
4 ms |
1356 KB |
Output is correct |
21 |
Correct |
1 ms |
332 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
1356 KB |
Output is correct |
2 |
Correct |
1 ms |
1356 KB |
Output is correct |
3 |
Correct |
1 ms |
1356 KB |
Output is correct |
4 |
Correct |
2 ms |
1356 KB |
Output is correct |
5 |
Correct |
1 ms |
1356 KB |
Output is correct |
6 |
Correct |
1 ms |
332 KB |
Output is correct |
7 |
Correct |
10 ms |
1356 KB |
Output is correct |
8 |
Correct |
4 ms |
1368 KB |
Output is correct |
9 |
Correct |
2 ms |
1356 KB |
Output is correct |
10 |
Correct |
1 ms |
1356 KB |
Output is correct |
11 |
Correct |
1 ms |
332 KB |
Output is correct |
12 |
Correct |
18 ms |
1420 KB |
Output is correct |
13 |
Correct |
24 ms |
1424 KB |
Output is correct |
14 |
Correct |
18 ms |
1360 KB |
Output is correct |
15 |
Correct |
2 ms |
1356 KB |
Output is correct |
16 |
Correct |
1 ms |
332 KB |
Output is correct |
17 |
Correct |
23 ms |
1356 KB |
Output is correct |
18 |
Correct |
26 ms |
1400 KB |
Output is correct |
19 |
Correct |
10 ms |
1356 KB |
Output is correct |
20 |
Correct |
4 ms |
1356 KB |
Output is correct |
21 |
Correct |
1 ms |
332 KB |
Output is correct |
22 |
Runtime error |
1 ms |
460 KB |
Execution killed with signal 11 |
23 |
Halted |
0 ms |
0 KB |
- |