# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
419882 | nicolaalexandra | Nautilus (BOI19_nautilus) | C++14 | 178 ms | 716 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>
#define DIM 510
using namespace std;
char v[DIM*10],s[DIM];
int n,m,k,i,j;
bitset <DIM> a[2][DIM],mask[DIM];
int main (){
//ifstream cin ("date.in");
//ofstream cout ("date.out");
cin>>n>>m>>k;
for (i=1;i<=n;i++){
cin>>s+1;
for (j=1;j<=m;j++)
if (s[j] == '.')
mask[i][j] = 1;
a[0][i] = mask[i];
}
cin>>v+1;
int t = 1;
for (int pas=1;pas<=k;pas++){
for (i=1;i<=n;i++)
a[t][i].reset();
for (i=1;i<=n;i++){
if (v[pas] == 'N' || v[pas] == '?')
a[t][i] |= a[1-t][i+1];
if (v[pas] == 'S' || v[pas] == '?')
a[t][i] |= a[1-t][i-1];
if (v[pas] == 'E' || v[pas] == '?')
a[t][i] |= (a[1-t][i] << 1);
if (v[pas] == 'W' || v[pas] == '?')
a[t][i] |= (a[1-t][i] >> 1);
a[t][i] &= mask[i];
}
t = 1-t;
}
int sol = 0;
for (i=1;i<=n;i++)
for (j=1;j<=m;j++)
sol += a[1-t][i][j];
cout<<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... |