이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
bitset<512> tmp[502],grd[502],pos[502];
int main() {
int r, c, m;
cin >> r >> c >> m;
for(int i = 1; i <= r; i++) {
for(int j = 1; j <= c; j++) {
char c = getchar();
if(j==1)
c=getchar();
grd[i][j]=(c=='.');
}
pos[i]=grd[i];
}
for(int i = 0; i < m; i++) {
char c = getchar();
if(!i) c=getchar();
for(int j = 1; j <= r; j++)
tmp[j]=pos[j], pos[j].reset();
for(int j = 1; j <= r; j++) {
if(c=='N'||c=='?')
pos[j]|=tmp[j+1];
if(c=='S'||c=='?')
pos[j]|=tmp[j-1];
if(c=='E'||c=='?')
pos[j]|=tmp[j]<<1;
if(c=='W'||c=='?')
pos[j]|=tmp[j]>>1;
pos[j]&=grd[j];
}
}
int ans = 0;
for(int i = 1; i <= r; i++)
ans+=pos[i].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... |