# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
723463 | lovrot | Nautilus (BOI19_nautilus) | C++17 | 181 ms | 616 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 <cstdio>
#include <cstring>
#include <bitset>
using namespace std;
const int N = 500;
bitset<N> M[2][N + 2], S[N + 2];
int main() {
int n, m, q;
scanf("%d%d%d", &n, &m, &q);
for(int i = 1; i <= n; i++)
for(int j = 0; j < m; j++) {
char c;
scanf(" %c", &c);
S[i].set(j, c == '.');
M[0][i].set(j, c == '.');
}
bool f = 0;
for(int t = 0; t < q; t++) {
char c;
scanf(" %c", &c);
f ^= 1;
for(int i = 1; i <= n; i++) {
if(c == 'W') M[f][i] = S[i] & (M[!f][i] >> 1);
else if(c == 'E') M[f][i] = S[i] & (M[!f][i] << 1);
else if(c == 'N') M[f][i] = S[i] & M[!f][i + 1];
else if(c == 'S') M[f][i] = S[i] & M[!f][i - 1];
else M[f][i] = S[i] & ((M[!f][i] << 1) | (M[!f][i] >> 1) | M[!f][i - 1] | M[!f][i + 1]);
}
}
int sol = 0;
for(int i = 1; i <= n; i++)
sol += M[f][i].count();
printf("%d\n", sol);
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... |