#include<bits/stdc++.h>
/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
*/
using namespace std;
#pragma GCC optimize ("unroll-loops,Ofast,O3")
#pragma GCC target("avx,avx2,fma")
#define F first
#define int short
#define S second
#define sz(x) (int)x.size()
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define NFS ios_base::sync_with_stdio(0) , cin.tie(0) , cout.tie(0) ;
#define file(s) if (fopen(s".in", "r")) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout)
//#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
typedef long long ll;
const long long inf = 1e18+777;
const int N = 5555;
int n, m, K;
bitset<555> used[N][555];
signed main(){
NFS;
cin >> n >> m >> K;
for(int i = 1; i <= n; ++i){
for(int j = 1; j <= m; ++j){
char x; cin >> x;
used[0][i][j] = (x == '.');
}
}
string s; cin >> s; s = ' ' + s;
for(int k = 1; k <= K; ++k){
for(int i = 1; i <= n; ++i){
used[k][i] = used[0][i];
if(s[k] == 'N'){
used[k][i] &= used[k-1][i+1];
}
if(s[k] == 'S'){
used[k][i] &= used[k-1][i-1];
}
if(s[k] == 'E'){
used[k][i] &= (used[k-1][i] << 1);
}
if(s[k] == 'W'){
used[k][i] &= (used[k-1][i] >> 1);
}
if(s[k] == '?'){
used[k][i] &= ((used[k-1][i] << 1)|(used[k-1][i] >> 1)|used[k-1][i-1]|used[k-1][i+1]);
}
}
}
long long res = 0;
for(int i = 1; i <= n; ++i){
res += used[K][i].count();
}
cout << res;
};
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
1356 KB |
Output is correct |
2 |
Correct |
1 ms |
1356 KB |
Output is correct |
3 |
Correct |
1 ms |
1356 KB |
Output is correct |
4 |
Correct |
1 ms |
1356 KB |
Output is correct |
5 |
Correct |
1 ms |
1356 KB |
Output is correct |
6 |
Correct |
1 ms |
1356 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
1356 KB |
Output is correct |
2 |
Correct |
1 ms |
1356 KB |
Output is correct |
3 |
Correct |
1 ms |
1356 KB |
Output is correct |
4 |
Correct |
1 ms |
1356 KB |
Output is correct |
5 |
Correct |
1 ms |
1356 KB |
Output is correct |
6 |
Correct |
1 ms |
1356 KB |
Output is correct |
7 |
Correct |
1 ms |
1356 KB |
Output is correct |
8 |
Correct |
1 ms |
1356 KB |
Output is correct |
9 |
Correct |
1 ms |
1356 KB |
Output is correct |
10 |
Correct |
1 ms |
1356 KB |
Output is correct |
11 |
Correct |
1 ms |
1356 KB |
Output is correct |
12 |
Correct |
1 ms |
1356 KB |
Output is correct |
13 |
Correct |
1 ms |
1356 KB |
Output is correct |
14 |
Correct |
1 ms |
1356 KB |
Output is correct |
15 |
Correct |
1 ms |
1356 KB |
Output is correct |
16 |
Correct |
1 ms |
1356 KB |
Output is correct |
17 |
Correct |
1 ms |
1356 KB |
Output is correct |
18 |
Correct |
1 ms |
1356 KB |
Output is correct |
19 |
Correct |
2 ms |
1356 KB |
Output is correct |
20 |
Correct |
1 ms |
1356 KB |
Output is correct |
21 |
Correct |
1 ms |
1356 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
1356 KB |
Output is correct |
2 |
Correct |
1 ms |
1356 KB |
Output is correct |
3 |
Correct |
1 ms |
1356 KB |
Output is correct |
4 |
Correct |
1 ms |
1356 KB |
Output is correct |
5 |
Correct |
1 ms |
1356 KB |
Output is correct |
6 |
Correct |
1 ms |
1356 KB |
Output is correct |
7 |
Correct |
1 ms |
1356 KB |
Output is correct |
8 |
Correct |
1 ms |
1356 KB |
Output is correct |
9 |
Correct |
1 ms |
1356 KB |
Output is correct |
10 |
Correct |
1 ms |
1356 KB |
Output is correct |
11 |
Correct |
1 ms |
1356 KB |
Output is correct |
12 |
Correct |
1 ms |
1356 KB |
Output is correct |
13 |
Correct |
1 ms |
1356 KB |
Output is correct |
14 |
Correct |
1 ms |
1356 KB |
Output is correct |
15 |
Correct |
1 ms |
1356 KB |
Output is correct |
16 |
Correct |
1 ms |
1356 KB |
Output is correct |
17 |
Correct |
1 ms |
1356 KB |
Output is correct |
18 |
Correct |
1 ms |
1356 KB |
Output is correct |
19 |
Correct |
2 ms |
1356 KB |
Output is correct |
20 |
Correct |
1 ms |
1356 KB |
Output is correct |
21 |
Correct |
1 ms |
1356 KB |
Output is correct |
22 |
Correct |
105 ms |
195804 KB |
Output is correct |
23 |
Correct |
106 ms |
195764 KB |
Output is correct |
24 |
Correct |
111 ms |
195848 KB |
Output is correct |
25 |
Correct |
103 ms |
195860 KB |
Output is correct |
26 |
Correct |
114 ms |
195780 KB |
Output is correct |
27 |
Correct |
111 ms |
195784 KB |
Output is correct |
28 |
Correct |
108 ms |
195852 KB |
Output is correct |
29 |
Correct |
108 ms |
195784 KB |
Output is correct |
30 |
Correct |
128 ms |
195904 KB |
Output is correct |
31 |
Correct |
129 ms |
195764 KB |
Output is correct |
32 |
Correct |
116 ms |
195768 KB |
Output is correct |
33 |
Correct |
115 ms |
195792 KB |
Output is correct |
34 |
Correct |
120 ms |
195828 KB |
Output is correct |
35 |
Correct |
132 ms |
195764 KB |
Output is correct |
36 |
Correct |
112 ms |
195816 KB |
Output is correct |