using namespace std;
#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>
#include <map>
#include <set>
#include <stack>
#include <queue>
typedef long long LL;
typedef pair<int,int> pii;
#define pb push_back
#define mkp make_pair
#define F first
#define S second
#define iter(x) x.begin(),x.end()
#define REP(n) for (int __=n;__--;)
#define REP0(i,n) for (int i=0;i<n;++i)
#define REP1(i,n) for (int i=1;i<=n;++i)
#include <bitset>
const int maxn = 505, mod = 0;
const LL inf = 0;
vector <bitset <maxn>> dp, can;
void solve(){
int n, m, k;
string s;
cin >> n >> m >> k;
can.resize(n);
REP0(i,n) REP0(j,m){
char c;
cin >> c;
can[i][j] = (c == '.');
}
//REP0(i,n) {REP0(j,m) cout << can[i][j]; cout << '\n';} cout << '\n';
dp = can;
cin >> s;
for (auto c:s){
vector <bitset<maxn>> tr(n);
if (c == 'E' or c == '?'){
REP0(i,n) tr[i] = tr[i] | (dp[i] << 1);
}
if (c == 'W' or c == '?'){
REP0(i,n) tr[i] = tr[i] | (dp[i] >> 1);
}
if (c == 'N' or c == '?'){
REP0(i,n-1) tr[i] = tr[i] | dp[i+1];
}
if (c == 'S' or c == '?'){
REP1(i,n-1) tr[i] = tr[i] | dp[i-1];
}
REP0(i, n){
tr[i] = tr[i] & can[i];
}
dp.swap(tr);
//cout << c << '\n'; REP0(i,n) {REP0(j,m) cout << dp[i][j]; cout << '\n';} cout << '\n';
}
int cnt = 0;
REP0(i,n) cnt += dp[i].count();
cout << cnt;
}
int main(){
ios_base::sync_with_stdio(false); cin.tie(0);
solve();
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
1 ms |
332 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
1 ms |
332 KB |
Output is correct |
5 |
Correct |
1 ms |
332 KB |
Output is correct |
6 |
Correct |
1 ms |
332 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
1 ms |
332 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
1 ms |
332 KB |
Output is correct |
5 |
Correct |
1 ms |
332 KB |
Output is correct |
6 |
Correct |
1 ms |
332 KB |
Output is correct |
7 |
Correct |
2 ms |
332 KB |
Output is correct |
8 |
Correct |
1 ms |
332 KB |
Output is correct |
9 |
Correct |
1 ms |
332 KB |
Output is correct |
10 |
Correct |
1 ms |
332 KB |
Output is correct |
11 |
Correct |
1 ms |
332 KB |
Output is correct |
12 |
Correct |
2 ms |
332 KB |
Output is correct |
13 |
Correct |
1 ms |
320 KB |
Output is correct |
14 |
Correct |
1 ms |
332 KB |
Output is correct |
15 |
Correct |
2 ms |
332 KB |
Output is correct |
16 |
Correct |
1 ms |
332 KB |
Output is correct |
17 |
Correct |
1 ms |
332 KB |
Output is correct |
18 |
Correct |
1 ms |
332 KB |
Output is correct |
19 |
Correct |
1 ms |
332 KB |
Output is correct |
20 |
Correct |
1 ms |
332 KB |
Output is correct |
21 |
Correct |
1 ms |
332 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
1 ms |
332 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
1 ms |
332 KB |
Output is correct |
5 |
Correct |
1 ms |
332 KB |
Output is correct |
6 |
Correct |
1 ms |
332 KB |
Output is correct |
7 |
Correct |
2 ms |
332 KB |
Output is correct |
8 |
Correct |
1 ms |
332 KB |
Output is correct |
9 |
Correct |
1 ms |
332 KB |
Output is correct |
10 |
Correct |
1 ms |
332 KB |
Output is correct |
11 |
Correct |
1 ms |
332 KB |
Output is correct |
12 |
Correct |
2 ms |
332 KB |
Output is correct |
13 |
Correct |
1 ms |
320 KB |
Output is correct |
14 |
Correct |
1 ms |
332 KB |
Output is correct |
15 |
Correct |
2 ms |
332 KB |
Output is correct |
16 |
Correct |
1 ms |
332 KB |
Output is correct |
17 |
Correct |
1 ms |
332 KB |
Output is correct |
18 |
Correct |
1 ms |
332 KB |
Output is correct |
19 |
Correct |
1 ms |
332 KB |
Output is correct |
20 |
Correct |
1 ms |
332 KB |
Output is correct |
21 |
Correct |
1 ms |
332 KB |
Output is correct |
22 |
Correct |
135 ms |
644 KB |
Output is correct |
23 |
Correct |
134 ms |
588 KB |
Output is correct |
24 |
Correct |
135 ms |
652 KB |
Output is correct |
25 |
Correct |
131 ms |
588 KB |
Output is correct |
26 |
Correct |
128 ms |
652 KB |
Output is correct |
27 |
Correct |
187 ms |
660 KB |
Output is correct |
28 |
Correct |
188 ms |
588 KB |
Output is correct |
29 |
Correct |
189 ms |
648 KB |
Output is correct |
30 |
Correct |
189 ms |
588 KB |
Output is correct |
31 |
Correct |
189 ms |
648 KB |
Output is correct |
32 |
Correct |
231 ms |
644 KB |
Output is correct |
33 |
Correct |
236 ms |
588 KB |
Output is correct |
34 |
Correct |
242 ms |
708 KB |
Output is correct |
35 |
Correct |
240 ms |
652 KB |
Output is correct |
36 |
Correct |
239 ms |
712 KB |
Output is correct |