# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
542716 | OttoTheDino | Nautilus (BOI19_nautilus) | C++17 | 0 ms | 0 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;
int main () {
int n, m, k; cin >> n >> m>>k;
bitset<500> b[n], sea[n];
for (int i = 0; i < n; ++i) {
for (int j = 0; j < m; ++j) {
char c; cin >> c;
b[i][j] = sea[i][j] = (c=='.');
}
}
for (int i=0;i<k;++i){
char c; cin >> c;
bitset<500> nb[n];
if (c=='N') {
for (int i=0;i<n-1;++i){
nb[i] = b[i+1];
}
}
else if (c=='S') {
for (int i=1;i<n;++i){
nb[i] = b[i-1];
}
}
else if (c=='W') {
for (int i=0;i<n;++i){
nb[i] = b[i]<<1;
}
}
else if (c=='E') {
for (int i=0;i<n;++i){
nb[i] = b[i]>>1;
}
}
else {
for (int i=0;i<n;++i){
if (i>1) nb[i] |= b[i-1];
if (i<n-1) nb[i] |= b[i+1];
nb[i] |= ((b[i]<<1)|(b[i]>>1));
nb[i] &= sea[i];
}
}
memcpy(b,nb,sizeof(nb));
}
int ans=0;
for (int i = 0; i <n; ++i){
ans += b[i].count();
}
cout << ans << ”\n”;
return 0;
}