# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
314126 | kimbj0709 | Nautilus (BOI19_nautilus) | C++14 | 199 ms | 512 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 = 505;
int32_t main() {
ios::sync_with_stdio(0);
cin.tie(0);cout.tie(0);
bitset<maxn> dp[maxn][2];
bitset<maxn> arr[maxn];
int n,m,len;
cin >> n >> m >> len;
string input;
char inp;
for(int i=1;i<=n;i++){
cin >> input;
for(int j=1;j<=m;j++){
if(input.at(j-1)=='.'){
arr[i][j] = 1;
}
}
dp[i][0] = arr[i];
}
cin >> input;
for(int i=0;i<len;i++){
for(int a=1;a<=n;a++){
if(input.at(i)=='N'){
dp[a][(i+1)&1] = dp[a+1][i&1];
}
if(input.at(i)=='S'){
dp[a][(i+1)&1] = dp[a-1][i&1];
}
if(input.at(i)=='W'){
dp[a][(i+1)&1] = dp[a][i&1] >> 1;
}
if(input.at(i)=='E'){
dp[a][(i+1)&1] = dp[a][i&1] << 1;
}
if(input.at(i)=='?'){
dp[a][(i+1)&1] = (dp[a][i&1] << 1)|(dp[a][i&1] >> 1)|(dp[a-1][i&1])|(dp[a+1][i&1]);
}
dp[a][(i+1)&1] &= arr[a];
}
}
int ans = 0;
for(int i=1;i<=n;i++){
ans += dp[i][(input.length())&1].count();
}
cout << 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... |