// PhuThuyRuntime <3
// A secret makes a woman woman
#include <bits/stdc++.h>
using namespace std;
#define eb emplace_back
#define ef emplace_front
#define pb push_back
#define pf push_front
#define all(v) v.begin(), v.end()
#define ins insert
#define lb lower_bound
#define ub upper_bound
#define fo(i, l, r) for(int i = l; i <= r; i++)
#define foi(i, l, r) for(int i = l; i >= r; i--)
#define elif else if
#define el cout << "\n";
#define pii pair<int, int>
#define pli pair<ll, int>
#define pll pair<ll, ll>
#define pil pair<int, ll>
#define fi first
#define se second
#define in(x) freopen(x, "r", stdin)
#define out(x) freopen(x, "w", stdout)
#define ll long long
#define ull unsigned long long
#define pob pop_back
#define vi vector<int>
#define vii vector<pair<int, int>>
#define getbit(i, j) ((i >> j) & 1)
#define offbit(i, j) ((1 << j) ^ i)
#define onbit(i, j) ((1 << j) | i)
const int N = 1e5 + 2;
const ll mod = 1e9 + 7;
const int inf = INT_MAX;
const int base = 31;
const long double EPS = 1e-9;
const long double pi = acos(-1.0);
int n, m, q;
char a[505][505];
bitset<505> bs[505], dp[505];
void inp(){
cin >> n >> m >> q;
fo(i, 1, n){
fo(j, 1, m){
cin >> a[i][j];
if(a[i][j] == '.') dp[i][j] = bs[i][j] = 1;
}
}
}
bitset<505> tmp[505];
void sol(){
while(q--){
char ch; cin >> ch;
if(ch == 'N'){
fo(i, 1, n) tmp[i] = bs[i] & dp[i + 1];
}
else if(ch == 'E'){
fo(i, 1, n) tmp[i] = bs[i] & (dp[i] << 1);
}
else if(ch == 'S'){
fo(i, 1, n) tmp[i] = bs[i] & dp[i - 1];
}
else if(ch == 'W'){
fo(i, 1, n) tmp[i] = bs[i] & (dp[i] >> 1);
}
else{
fo(i, 1, n) tmp[i] = bs[i] & (dp[i + 1] | dp[i - 1] | (dp[i] << 1) | (dp[i] >> 1));
}
fo(i, 1, n) dp[i] = tmp[i];
}
int ans = 0;
fo(i, 1, n) ans += dp[i].count();
cout << ans;
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
inp();
sol();
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
1 ms |
336 KB |
Output is correct |
3 |
Correct |
1 ms |
336 KB |
Output is correct |
4 |
Correct |
1 ms |
552 KB |
Output is correct |
5 |
Correct |
1 ms |
336 KB |
Output is correct |
6 |
Correct |
1 ms |
336 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
1 ms |
336 KB |
Output is correct |
3 |
Correct |
1 ms |
336 KB |
Output is correct |
4 |
Correct |
1 ms |
552 KB |
Output is correct |
5 |
Correct |
1 ms |
336 KB |
Output is correct |
6 |
Correct |
1 ms |
336 KB |
Output is correct |
7 |
Correct |
1 ms |
336 KB |
Output is correct |
8 |
Correct |
1 ms |
336 KB |
Output is correct |
9 |
Correct |
2 ms |
336 KB |
Output is correct |
10 |
Correct |
1 ms |
476 KB |
Output is correct |
11 |
Correct |
1 ms |
336 KB |
Output is correct |
12 |
Correct |
1 ms |
472 KB |
Output is correct |
13 |
Correct |
1 ms |
336 KB |
Output is correct |
14 |
Correct |
1 ms |
336 KB |
Output is correct |
15 |
Correct |
2 ms |
336 KB |
Output is correct |
16 |
Correct |
2 ms |
336 KB |
Output is correct |
17 |
Correct |
2 ms |
336 KB |
Output is correct |
18 |
Correct |
2 ms |
336 KB |
Output is correct |
19 |
Correct |
2 ms |
336 KB |
Output is correct |
20 |
Correct |
2 ms |
336 KB |
Output is correct |
21 |
Correct |
2 ms |
504 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
1 ms |
336 KB |
Output is correct |
3 |
Correct |
1 ms |
336 KB |
Output is correct |
4 |
Correct |
1 ms |
552 KB |
Output is correct |
5 |
Correct |
1 ms |
336 KB |
Output is correct |
6 |
Correct |
1 ms |
336 KB |
Output is correct |
7 |
Correct |
1 ms |
336 KB |
Output is correct |
8 |
Correct |
1 ms |
336 KB |
Output is correct |
9 |
Correct |
2 ms |
336 KB |
Output is correct |
10 |
Correct |
1 ms |
476 KB |
Output is correct |
11 |
Correct |
1 ms |
336 KB |
Output is correct |
12 |
Correct |
1 ms |
472 KB |
Output is correct |
13 |
Correct |
1 ms |
336 KB |
Output is correct |
14 |
Correct |
1 ms |
336 KB |
Output is correct |
15 |
Correct |
2 ms |
336 KB |
Output is correct |
16 |
Correct |
2 ms |
336 KB |
Output is correct |
17 |
Correct |
2 ms |
336 KB |
Output is correct |
18 |
Correct |
2 ms |
336 KB |
Output is correct |
19 |
Correct |
2 ms |
336 KB |
Output is correct |
20 |
Correct |
2 ms |
336 KB |
Output is correct |
21 |
Correct |
2 ms |
504 KB |
Output is correct |
22 |
Correct |
95 ms |
848 KB |
Output is correct |
23 |
Correct |
90 ms |
848 KB |
Output is correct |
24 |
Correct |
89 ms |
848 KB |
Output is correct |
25 |
Correct |
89 ms |
848 KB |
Output is correct |
26 |
Correct |
87 ms |
848 KB |
Output is correct |
27 |
Correct |
136 ms |
996 KB |
Output is correct |
28 |
Correct |
142 ms |
848 KB |
Output is correct |
29 |
Correct |
138 ms |
848 KB |
Output is correct |
30 |
Correct |
148 ms |
860 KB |
Output is correct |
31 |
Correct |
140 ms |
864 KB |
Output is correct |
32 |
Correct |
181 ms |
848 KB |
Output is correct |
33 |
Correct |
176 ms |
968 KB |
Output is correct |
34 |
Correct |
181 ms |
848 KB |
Output is correct |
35 |
Correct |
178 ms |
1060 KB |
Output is correct |
36 |
Correct |
180 ms |
848 KB |
Output is correct |