#include <bits/stdc++.h>
#define st first
#define nd second
#define ll long long
#define ull unsigned long long
#define pii pair <int,int>
#define pll pair <ll,ll>
#define piii pair <int,pii>
#define vi vector <int>
#define pb push_back
#define mp make_pair
#define forr(_a,_b,_c) for(int _a = _b; _a <= _c; ++_a)
#define ford(_a,_b,_c) for(int _a = (_b) + 1; _a --> _c;)
#define forf(_a,_b,_c) for(int _a = _b; _a < _c; ++_a)
#define all(x) begin(x),end(x)
#define file "test"
using namespace std;
const int N=2e5 + 5;
const ll oo = 1e9;
bitset <10> bit[502],f[5002][502];
int r,c,M;
string a[505],m;
int main(){
ios_base::sync_with_stdio(0); cin.tie(0);
cin >> r >> c >> M;
forf (i,0,r)
cin >> a[i];
cin >> m;
memset(f,0,sizeof f);
memset(bit,0,sizeof bit);
m = '*' + m;
forf (i,0,r)
forf (j,0,c)
if (a[i][j] == '.')
bit[i] |= (1 << (c - j - 1));
forf (i,0,r)
f[0][i] = (bit[i]);
forr (i,1,M)
{
//cout << m[i] << endl;
forf (j,0,r)
{
if (m[i] == 'W')
f[i][j] = (f[i-1][j] << 1) & f[0][j];
if (m[i] == 'E')
f[i][j] = (f[i-1][j] >> 1) & f[0][j];
if (m[i] == 'N' && j < r - 1)
f[i][j] = f[i-1][j+1] & f[0][j];
if (m[i] == 'S' && j != 0)
f[i][j] = f[i-1][j - 1] & f[0][j];
if (m[i] == '?')
f[i][j] = ((f[i-1][j] << 1) | (f[i-1][j] >> 1) | f[i-1][j+1] | f[i-1][j - 1]) & f[0][j];
// cout << f[i][j] << endl;
}
// cout << endl;
}
int ans = 0;
forf (i,0,r)
ans += f[M][i].count();
cout << ans;
return 0;
}
/*
*/
Compilation message
nautilus.cpp: In function 'int main()':
nautilus.cpp:31:28: warning: 'void* memset(void*, int, size_t)' clearing an object of non-trivial type 'class std::bitset<10>'; use assignment or value-initialization instead [-Wclass-memaccess]
31 | memset(bit,0,sizeof bit);
| ^
In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:66,
from nautilus.cpp:1:
/usr/include/c++/10/bitset:751:11: note: 'class std::bitset<10>' declared here
751 | class bitset
| ^~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
8 ms |
19940 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
8 ms |
19940 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
8 ms |
19940 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |