#include <bits/stdc++.h> //Andrei Alexandru a.k.a Sho10
#define ll long long
#define double long double
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#define all(a) (a).begin(), (a).end()
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define pi pair
#define rc(s) return cout<<s,0
#define endl '\n'
#define mod 1000000007
#define PI 3.14159265359
#define MAXN 100005
#define INF 1000000005
#define LINF 1000000000000000005ll
#define CODE_START ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
int n,m,k;
bitset<2500005>a,dp;
int32_t main(){
CODE_START;
cin>>n>>m>>k;
for(int i=0;i<=n+1;i++)
{
for(int j=0;j<=m+1;j++)
{
a[(m+2)*i+j]=0;
}
}
for(int i=1;i<=n;i++)
{
string x;
cin>>x;
for(int j=1;j<=m;j++)
{
a[(m+2)*i+j]=(x[j-1]=='.');
}
}
dp|=a;
string s;
cin>>s;
for(auto it : s){
if(it=='N'){
dp=(a&(dp>>(m+2)));
}else if(it=='S'){
dp=(a&(dp<<(m+2)));
}else if(it=='E'){
dp=(a&(dp<<1));
}else if(it=='W'){
dp=(a&(dp>>1));
}else {
dp=(a&((dp<<1)|(dp>>1)|(dp<<(m+2))|(dp>>(m+2))));
}
}
cout<<dp.count()<<endl;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
12 ms |
1516 KB |
Output is correct |
2 |
Correct |
12 ms |
1536 KB |
Output is correct |
3 |
Correct |
12 ms |
1516 KB |
Output is correct |
4 |
Correct |
12 ms |
1516 KB |
Output is correct |
5 |
Correct |
12 ms |
1516 KB |
Output is correct |
6 |
Correct |
12 ms |
1516 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
12 ms |
1516 KB |
Output is correct |
2 |
Correct |
12 ms |
1536 KB |
Output is correct |
3 |
Correct |
12 ms |
1516 KB |
Output is correct |
4 |
Correct |
12 ms |
1516 KB |
Output is correct |
5 |
Correct |
12 ms |
1516 KB |
Output is correct |
6 |
Correct |
12 ms |
1516 KB |
Output is correct |
7 |
Correct |
21 ms |
3436 KB |
Output is correct |
8 |
Correct |
21 ms |
3436 KB |
Output is correct |
9 |
Correct |
22 ms |
3436 KB |
Output is correct |
10 |
Correct |
24 ms |
3436 KB |
Output is correct |
11 |
Correct |
23 ms |
3436 KB |
Output is correct |
12 |
Correct |
32 ms |
3436 KB |
Output is correct |
13 |
Correct |
33 ms |
3436 KB |
Output is correct |
14 |
Correct |
34 ms |
3456 KB |
Output is correct |
15 |
Correct |
33 ms |
3436 KB |
Output is correct |
16 |
Correct |
33 ms |
3436 KB |
Output is correct |
17 |
Correct |
41 ms |
3072 KB |
Output is correct |
18 |
Correct |
42 ms |
3052 KB |
Output is correct |
19 |
Correct |
40 ms |
3052 KB |
Output is correct |
20 |
Correct |
40 ms |
3052 KB |
Output is correct |
21 |
Correct |
40 ms |
3052 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
12 ms |
1516 KB |
Output is correct |
2 |
Correct |
12 ms |
1536 KB |
Output is correct |
3 |
Correct |
12 ms |
1516 KB |
Output is correct |
4 |
Correct |
12 ms |
1516 KB |
Output is correct |
5 |
Correct |
12 ms |
1516 KB |
Output is correct |
6 |
Correct |
12 ms |
1516 KB |
Output is correct |
7 |
Correct |
21 ms |
3436 KB |
Output is correct |
8 |
Correct |
21 ms |
3436 KB |
Output is correct |
9 |
Correct |
22 ms |
3436 KB |
Output is correct |
10 |
Correct |
24 ms |
3436 KB |
Output is correct |
11 |
Correct |
23 ms |
3436 KB |
Output is correct |
12 |
Correct |
32 ms |
3436 KB |
Output is correct |
13 |
Correct |
33 ms |
3436 KB |
Output is correct |
14 |
Correct |
34 ms |
3456 KB |
Output is correct |
15 |
Correct |
33 ms |
3436 KB |
Output is correct |
16 |
Correct |
33 ms |
3436 KB |
Output is correct |
17 |
Correct |
41 ms |
3072 KB |
Output is correct |
18 |
Correct |
42 ms |
3052 KB |
Output is correct |
19 |
Correct |
40 ms |
3052 KB |
Output is correct |
20 |
Correct |
40 ms |
3052 KB |
Output is correct |
21 |
Correct |
40 ms |
3052 KB |
Output is correct |
22 |
Correct |
901 ms |
3584 KB |
Output is correct |
23 |
Correct |
900 ms |
3436 KB |
Output is correct |
24 |
Correct |
881 ms |
3564 KB |
Output is correct |
25 |
Correct |
879 ms |
3564 KB |
Output is correct |
26 |
Correct |
862 ms |
3436 KB |
Output is correct |
27 |
Execution timed out |
1054 ms |
3436 KB |
Time limit exceeded |
28 |
Halted |
0 ms |
0 KB |
- |