이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#pragma GCC optimize("Ofast,unroll-loops")
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define sp << ' ' <<
#define nl << '\n'
const int sz = 500*500;
signed main(){
cin.tie(0)->sync_with_stdio(0);
int r, c, m; cin >> r >> c >> m;
char inp;
bitset<sz> a, b, x, y, g;
for(int i=0; i<r; ++i){
for(int j=0; j<c; ++j){
cin >> inp;
g[i*c+j] = b[i*c+j] = (inp == '.');
x[i*c+j] = j!=0;
y[i*c+j] = j!=c-1;
}
}
string s; cin >> s;
for(int k=0; k<m; ++k){
a = b;
b = bitset<sz>(0);
if(s[k] == 'S' or s[k] == '?') b |= (a << c);
if(s[k] == 'N' or s[k] == '?') b |= (a >> c);
if(s[k] == 'E' or s[k] == '?') b |= (a << 1) & x;
if(s[k] == 'W' or s[k] == '?') b |= (a >> 1) & y;
b = b & g;
}
int res = 0;
for(int i=0; i<r; ++i)
for(int j=0; j<c; ++j)
res += b[i*c+j];
cout << res;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |