# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
130975 | PeppaPig | Nautilus (BOI19_nautilus) | C++14 | 222 ms | 1016 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
const int N = 505;
const int M = 5e3+5;
int r, c, m;
char a[N][N], dir[M];
bitset<N> mask[N], dp[N];
int main() {
scanf("%d %d %d", &r, &c, &m);
for(int i = 0; i < r; i++) {
scanf(" %s", a[i]);
for(int j = 0; j < c; j++) {
if(a[i][j] == '#') mask[i][j] = dp[i][j] = 0;
else mask[i][j] = dp[i][j] = 1;
}
}
scanf(" %s", dir);
for(int i = 0; i < m; i++) {
bitset<N> ndp[N];
for(int j = 0; j < r; j++) ndp[j] = 0;
if(dir[i] == 'N' || dir[i] == '?') for(int j = 0; j < r - 1; j++)
ndp[j] |= dp[j + 1];
if(dir[i] == 'S' || dir[i] == '?') for(int j = 1; j < r; j++)
ndp[j] |= dp[j - 1];
if(dir[i] == 'W' || dir[i] == '?') for(int j = 0; j < r; j++)
ndp[j] |= dp[j] >> 1;
if(dir[i] == 'E' || dir[i] == '?') for(int j = 0; j < r; j++)
ndp[j] |= dp[j] << 1;
for(int j = 0; j < r; j++) dp[j] = ndp[j] & mask[j];
}
int ans = 0;
for(int i = 0; i < r; i++) ans += dp[i].count();
printf("%d\n", ans);
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |