# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
243342 | Lawliet | Nautilus (BOI19_nautilus) | C++17 | 283 ms | 768 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;
const int MAXT = 5010;
int n, m, k;
string s;
bitset<MAXN> dp[MAXN][2], v[MAXN];
int main()
{
cin >> n >> m >> k;
for(int i = 1 ; i <= n ; i++)
{
for(int j = 1 ; j <= m ; j++)
{
char c;
scanf(" %c",&c);
if( c == '.' ) v[i][j] = 1;
}
}
cin >> s;
for(int i = 1 ; i <= n ; i++)
dp[i][1] = v[i];
for(int t = 0 ; t < k ; t++)
{
for(int i = 1 ; i <= n ; i++)
{
dp[i][t%2].reset();
if( s[t] == 'N' || s[t] == '?' ) dp[i][t%2] = ( dp[i][t%2] | dp[i + 1][1 - t%2] );
if( s[t] == 'S' || s[t] == '?' ) dp[i][t%2] = ( dp[i][t%2] | dp[i - 1][1 - t%2] );
if( s[t] == 'E' || s[t] == '?' ) dp[i][t%2] = ( dp[i][t%2] | ( dp[i][1 - t%2] << 1 ) );
if( s[t] == 'W' || s[t] == '?' ) dp[i][t%2] = ( dp[i][t%2] | ( dp[i][1 - t%2] >> 1 ) );
dp[i][t%2] = ( dp[i][t%2] & v[i] );
}
}
int ans = 0;
for(int i = 1 ; i <= n ; i++)
ans += dp[i][1 - k%2].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... |