# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
148111 | WhipppedCream | Nautilus (BOI19_nautilus) | C++17 | 297 ms | 1400 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>
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
using namespace std;
#define X first
#define Y second
#define pb push_back
typedef pair<int, int> ii;
typedef long long ll;
const int maxn = 505;
const int maxs = 50005;
const int sz = 500*500;
int n, m, k;
char arr[maxn][maxn];
char dir[maxs];
int main()
{
scanf("%d %d %d", &n, &m, &k);
for(int i = 0; i< n; i++) scanf("%s", arr[i]);
bitset<sz> mask;
bitset<sz> mright, mleft;
mright.set(); mleft.set();
for(int i = 0; i< n; i++)
{
for(int j = 0; j< m; j++)
{
if(arr[i][j] == '#') mask[i*m+j] = 0;
else mask[i*m+j] = 1;
if(j == 0) mleft[i*m+j] = 0;
if(j == m-1) mright[i*m+j] = 0;
}
}
bitset<sz> dp;
for(int i = 0; i< n; i++)
{
for(int j = 0; j< m; j++)
{
dp[i*m+j] = 1;
}
}
dp &= mask;
// printf("%d\n", dp.count());
scanf("%s", dir);
for(int i = 0; i< k; i++)
{
if(dir[i] == 'N')
{
dp = dp>>m;
}
else if(dir[i] == 'S')
{
dp = dp<<m;
}
else if(dir[i] == 'E')
{
dp = (dp<<1)&mleft;
}
else if(dir[i] == 'W')
{
dp = (dp>>1)&mright;
}
else
{
dp = (dp>>m)|(dp<<m)|((dp<<1)&mleft)|((dp>>1)&mright);
}
dp &= mask;
}
printf("%d\n", (int) dp.count());
}
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... |