This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
//IN THE NAME OF GOD
#include<bits/stdc++.h>
#pragma GCC optimize("O2,unroll-loops")
#define endl '\n'
#define F first
#define S second
using namespace std;
typedef long long ll;
const int N = 507;
bitset<N*N> must,ans,cop;
int32_t main(){
ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
int r,c,m; cin >> r >> c >> m;
for(int i=1; i<=r; i++){
for(int j=1; j<=c; j++){
char x; cin >> x;
if (x == '.') must[i*N+j] = ans[i*N+j] = 1;
else must[i*N+j] = ans[i*N+j] = 0;
}
}
for(int i=1; i<=m; i++){
char x; cin >> x;
cop = ans;
if (x == 'N') ans = (cop >> N);
else if (x == 'S') ans = (cop << N);
else if (x == 'E') ans = (cop << 1);
else if (x == 'W') ans = (cop >> 1);
else ans = ((cop>>N)|(cop<<N)|(cop<<1)|(cop>>1));
ans &= must;
}
cout << ans.count() << endl;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |