# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
647571 | berr | Nautilus (BOI19_nautilus) | C++17 | 191 ms | 724 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;
int32_t main()
{
ios_base::sync_with_stdio(false); cin.tie(0);
int n, m, k; cin>>n>>m>>k;
bitset<505> grid[n], sea[n];
for(int i=0; i<n; i++)
{
for(int l=0; l<m; l++)
{
char x; cin>>x;
if(x=='.') sea[i][l]=grid[i][l]=1;
else sea[i][l]=grid[i][l]=0;
}
}
string s; cin>>s;
for(int i=0; i<s.size(); i++)
{
bitset<505> tmp[n];
if(s[i]=='W'||s[i]=='?')
{
for(int l=0; l<n; l++)
{
tmp[l]|=(sea[l]&(grid[l]>>1));
}
}
if(s[i]=='E'||s[i]=='?')
{
for(int l=0; l<n; l++)
{
tmp[l]|=sea[l]&(grid[l]<<1);
}
}
if(s[i]=='N'||s[i]=='?')
{
for(int l=0; l<n-1; l++)
{
tmp[l]|=(sea[l]&grid[l+1]);
}
}
if(s[i]=='S'||s[i]=='?')
{
for(int l=1; l<n; l++)
{
tmp[l]|=sea[l]&grid[l-1];
}
}
for(int l=0; l<n; l++)
{
grid[l]=tmp[l];
}
}
int ans=0;
for(int i=0; i<n; i++)
{
for(int l=0; l<m; l++)
{
if(grid[i][l]) ans++;
}
}
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... |