# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
362959 | Kenzo_1114 | Nautilus (BOI19_nautilus) | C++17 | 223 ms | 748 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 MAXN = 510;
int n, m, q;
char cur;
bitset<MAXN> dp[2][MAXN], base[MAXN];
int main ()
{
scanf("%d %d %d", &n, &m, &q);
for(int i = 1; i <= n; i++)
for(int j = 1; j <= m; j++)
{
scanf(" %c", &cur);
dp[0][i][j] = base[i][j] = (cur == '.');
}
for(int K = 1, k; K <= q; K++)
{
k = K & 1;
scanf(" %c", &cur);
for(int i = 1; i <= n; i++)
{
if(cur == 'N') dp[k][i] = dp[!k][i + 1];
if(cur == 'E') dp[k][i] = dp[!k][i] << 1;
if(cur == 'S') dp[k][i] = dp[!k][i - 1];
if(cur == 'W') dp[k][i] = dp[!k][i] >> 1;
if(cur == '?') dp[k][i] = dp[!k][i + 1] | (dp[!k][i] >> 1) | dp[!k][i - 1] | (dp[!k][i] << 1);
dp[k][i] &= base[i];
}
}
int ans = 0;
for(int i = 1; i <= n; i++)
ans += dp[q & 1][i].count();
printf("%d\n", ans);
}
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... |