이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <iostream>
#include <bitset>
using namespace std;
char g[501][501],dir;
int n,m,M;
bitset<501> row[501][5002];
int main()
{
cin.tie(0);
cout.tie(0);
ios::sync_with_stdio(0);
cin>>n>>m>>M;
for(int i=0;i<n;i++)
{
for(int j=0;j<m;j++)
{
cin>>g[i][j];
row[i][0][j]=(g[i][j]=='.');
}
}
for(int j=0;j<M;j++)
{
cin>>dir;
bool p=0;
if(dir=='?')
p=1;
if(dir=='N' or p)
{
for(int i=1;i<n;i++)
row[i-1][j+1]|=(row[i][j]&row[i-1][0]);
}
if(dir=='E' or p)
{
for(int i=0;i<n;i++)
row[i][j+1]|=((row[i][j]<<1)&row[i][0]);
}
if(dir=='S' or p)
{
for(int i=0;i<(n-1);i++)
row[i+1][j+1]|=(row[i+1][0]&row[i][j]);
}
if(dir=='W' or p)
{
for(int i=0;i<n;i++)
row[i][j+1]|=((row[i][j]>>1)&row[i][0]);
}
}
int ans=0;
for(int x=0;x<n;x++)
ans+=row[x][M].count();
cout<<ans<<'\n';
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |