This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
bitset <500> dpp[505];
bitset <500> dp[505];
bitset <500> rows[505];
int main(){
ios_base::sync_with_stdio(false), cin.tie(0);
cout.precision(10);
cout << fixed;
int n, m, k;
cin >> n >> m >> k;
for(int i=1; i<=n; i++){
string s;
cin >> s;
for(int j=0; j<m; j++){
if(s[j] == '.') dp[i][j] = rows[i][j] = 1;
}
}
while(k--){
for(int i=1; i<=n; i++) dpp[i] = dp[i];
char c;
cin >> c;
if(c == 'W'){
for(int i=1; i<=n; i++) dp[i] = (dpp[i] >> 1);
}
else if(c == 'E'){
for(int i=1; i<=n; i++) dp[i] = (dpp[i] << 1);
}
else if(c == 'N'){
for(int i=1; i<=n; i++) dp[i] = dpp[i+1];
}
else if(c == 'S'){
for(int i=1; i<=n; i++) dp[i] = dpp[i-1];
}
else{
for(int i=1; i<=n; i++){
dp[i] = (dpp[i] << 1);
dp[i] |= (dpp[i] >> 1);
dp[i] |= dpp[i+1];
dp[i] |= dpp[i-1];
}
}
for(int i=1; i<=n; i++) dp[i] &= rows[i];
}
int res = 0;
for(int i=1; i<=n; i++){
res += dp[i].count();
}
cout << res << "\n";
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... |