#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC target ("avx2")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx")
#pragma GCC optimize("unroll-loops")
#include<iostream>
#include<cassert>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<vector>
#include<stack>
#include<set>
#include<queue>
#include<map>
#include<iomanip>
#include<bitset>
using namespace std;
const int N = (int)4e5 + 7;
const int inf = (int)1e9 + 7;
const int MOD = (int)998244353;
const long long INF = (long long)1e18 + 7;
int mult(int x, int y) {
return 1ll*x*y%MOD;
}
int sum(int x, int y) {
x += y;
if(x >= MOD) {
x -= MOD;
}
return x;
}
int sub(int x, int y) {
x -= y;
if(x < 0) {
x += MOD;
}
return x;
}
int n, m, k;
vector<pair<int, int> > dir[300];
void init() {
dir['W'] = {{0, -1}};
dir['E'] = {{0, +1}};
dir['N'] = {{-1, 0}};
dir['S'] = {{+1, 0}};
dir['?'] = {{0, -1}, {0, +1}, {-1, 0}, {+1, 0}};
}
int main() {
ios_base::sync_with_stdio(NULL);
cin.tie(0);
init();
cin >> n >> m >> k;
char a[n+1][m+1];
bool is[n+1][m+1];
bitset<505> used[2][501];
bitset<505> block[501];
memset(is, 0, sizeof(is));
for(int i = 0; i < n; ++i) {
used[1][i].reset();
for(int j = 0; j < m; ++j) {
cin >> a[i][j];
if(a[i][j] == '.') {
used[0][i][j]=1;
} else {
block[i][j]=1;
}
}
}
string s;
cin >> s;
s = '#'+s;
for(int id = 1; id <= k; ++id) {
if(s[id] == 'W' || s[id] == '?') {
for(int i = 0; i < n; ++i) {
used[1][i] |= (used[0][i]>>1);
}
}
if(s[id] == 'E' || s[id] == '?') {
for(int i = 0; i < n; ++i) {
used[1][i] |= (used[0][i]<<1);
}
}
if(s[id] == 'N' || s[id] == '?') {
for(int i = 0; i < n-1; ++i) {
used[1][i] |= used[0][i+1];
}
}
if(s[id] == 'S' || s[id] == '?') {
for(int i = 1; i < n; ++i) {
used[1][i] |= used[0][i-1];
}
}
for(int i = 0; i < n; ++i) {
used[1][i] |= block[i];
used[1][i] ^= block[i];
used[0][i] = used[1][i];
used[0][i][m] = 0;
used[1][i].reset();
}
}
int ans = 0;
for(int i = 0; i < n; ++i) {
for(int j = 0; j < m; ++j) {
if(used[0][i][j]) {
assert(a[i][j] == '.');
}
ans += used[0][i][j];
}
}
cout << ans << "\n";
return 0;
}
Compilation message
nautilus.cpp:1: warning: ignoring '#pragma comment ' [-Wunknown-pragmas]
1 | #pragma comment(linker, "/stack:200000000")
|
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
344 KB |
Output is correct |
3 |
Correct |
1 ms |
344 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
344 KB |
Output is correct |
3 |
Correct |
1 ms |
344 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
12 |
Correct |
1 ms |
348 KB |
Output is correct |
13 |
Correct |
1 ms |
348 KB |
Output is correct |
14 |
Correct |
1 ms |
348 KB |
Output is correct |
15 |
Correct |
1 ms |
348 KB |
Output is correct |
16 |
Correct |
1 ms |
348 KB |
Output is correct |
17 |
Correct |
1 ms |
348 KB |
Output is correct |
18 |
Correct |
1 ms |
348 KB |
Output is correct |
19 |
Correct |
1 ms |
348 KB |
Output is correct |
20 |
Correct |
1 ms |
348 KB |
Output is correct |
21 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
344 KB |
Output is correct |
3 |
Correct |
1 ms |
344 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
12 |
Correct |
1 ms |
348 KB |
Output is correct |
13 |
Correct |
1 ms |
348 KB |
Output is correct |
14 |
Correct |
1 ms |
348 KB |
Output is correct |
15 |
Correct |
1 ms |
348 KB |
Output is correct |
16 |
Correct |
1 ms |
348 KB |
Output is correct |
17 |
Correct |
1 ms |
348 KB |
Output is correct |
18 |
Correct |
1 ms |
348 KB |
Output is correct |
19 |
Correct |
1 ms |
348 KB |
Output is correct |
20 |
Correct |
1 ms |
348 KB |
Output is correct |
21 |
Correct |
1 ms |
348 KB |
Output is correct |
22 |
Correct |
41 ms |
856 KB |
Output is correct |
23 |
Correct |
43 ms |
860 KB |
Output is correct |
24 |
Correct |
41 ms |
860 KB |
Output is correct |
25 |
Correct |
40 ms |
856 KB |
Output is correct |
26 |
Correct |
39 ms |
860 KB |
Output is correct |
27 |
Correct |
56 ms |
860 KB |
Output is correct |
28 |
Correct |
58 ms |
1036 KB |
Output is correct |
29 |
Correct |
58 ms |
1040 KB |
Output is correct |
30 |
Correct |
58 ms |
860 KB |
Output is correct |
31 |
Correct |
56 ms |
860 KB |
Output is correct |
32 |
Correct |
69 ms |
1060 KB |
Output is correct |
33 |
Correct |
70 ms |
1036 KB |
Output is correct |
34 |
Correct |
71 ms |
1112 KB |
Output is correct |
35 |
Correct |
72 ms |
1032 KB |
Output is correct |
36 |
Correct |
69 ms |
860 KB |
Output is correct |