#include <bits/stdc++.h>
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,popcnt,lzcnt")
#define fio ios_base::sync_with_stdio(0);cin.tie(0);
#define ll long long
#define en cin.close();return 0;
#define pb push_back
#define fi first//printf("%lli\n",cur);
#define se second//scanf("%lli",&n);
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int N = 505;
bitset<N*N> gr, lft, rgt, cur;
int main()
{
fio
// ifstream cin("in.in");
int n, m, k;
cin >> n >> m >> k;
for(int i = 0;i<n;i++)
{
for(int j = 0;j<m;j++)
{
int ind = i*m+j;
char c;
cin >> c;
if(c=='.')
{
gr[ind]=cur[ind]=1;
if(j!=m-1)
lft[ind]=1;
if(j!=0)
rgt[ind]=1;
}
}
}
string str;
cin >> str;
for(auto x:str)
{
if(x=='N')
cur=(cur>>m)&gr;
else if(x=='S')
cur=(cur<<m)&gr;
else if(x=='W')
cur=(cur>>1)&lft;
else if(x=='E')
cur=(cur<<1)&rgt;
else
cur=((cur>>m)&gr)|((cur<<m)&gr)|((cur>>1)&lft)|((cur<<1)&rgt);
}
cout << cur.count();
// cin.close();
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
724 KB |
Output is correct |
2 |
Correct |
2 ms |
724 KB |
Output is correct |
3 |
Correct |
2 ms |
724 KB |
Output is correct |
4 |
Correct |
2 ms |
680 KB |
Output is correct |
5 |
Correct |
1 ms |
684 KB |
Output is correct |
6 |
Correct |
1 ms |
724 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
724 KB |
Output is correct |
2 |
Correct |
2 ms |
724 KB |
Output is correct |
3 |
Correct |
2 ms |
724 KB |
Output is correct |
4 |
Correct |
2 ms |
680 KB |
Output is correct |
5 |
Correct |
1 ms |
684 KB |
Output is correct |
6 |
Correct |
1 ms |
724 KB |
Output is correct |
7 |
Correct |
2 ms |
724 KB |
Output is correct |
8 |
Correct |
2 ms |
724 KB |
Output is correct |
9 |
Correct |
2 ms |
724 KB |
Output is correct |
10 |
Correct |
2 ms |
680 KB |
Output is correct |
11 |
Correct |
2 ms |
724 KB |
Output is correct |
12 |
Correct |
3 ms |
724 KB |
Output is correct |
13 |
Correct |
3 ms |
724 KB |
Output is correct |
14 |
Correct |
3 ms |
676 KB |
Output is correct |
15 |
Correct |
3 ms |
724 KB |
Output is correct |
16 |
Correct |
3 ms |
724 KB |
Output is correct |
17 |
Correct |
3 ms |
676 KB |
Output is correct |
18 |
Correct |
3 ms |
672 KB |
Output is correct |
19 |
Correct |
3 ms |
724 KB |
Output is correct |
20 |
Correct |
3 ms |
724 KB |
Output is correct |
21 |
Correct |
3 ms |
724 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
724 KB |
Output is correct |
2 |
Correct |
2 ms |
724 KB |
Output is correct |
3 |
Correct |
2 ms |
724 KB |
Output is correct |
4 |
Correct |
2 ms |
680 KB |
Output is correct |
5 |
Correct |
1 ms |
684 KB |
Output is correct |
6 |
Correct |
1 ms |
724 KB |
Output is correct |
7 |
Correct |
2 ms |
724 KB |
Output is correct |
8 |
Correct |
2 ms |
724 KB |
Output is correct |
9 |
Correct |
2 ms |
724 KB |
Output is correct |
10 |
Correct |
2 ms |
680 KB |
Output is correct |
11 |
Correct |
2 ms |
724 KB |
Output is correct |
12 |
Correct |
3 ms |
724 KB |
Output is correct |
13 |
Correct |
3 ms |
724 KB |
Output is correct |
14 |
Correct |
3 ms |
676 KB |
Output is correct |
15 |
Correct |
3 ms |
724 KB |
Output is correct |
16 |
Correct |
3 ms |
724 KB |
Output is correct |
17 |
Correct |
3 ms |
676 KB |
Output is correct |
18 |
Correct |
3 ms |
672 KB |
Output is correct |
19 |
Correct |
3 ms |
724 KB |
Output is correct |
20 |
Correct |
3 ms |
724 KB |
Output is correct |
21 |
Correct |
3 ms |
724 KB |
Output is correct |
22 |
Correct |
74 ms |
1064 KB |
Output is correct |
23 |
Correct |
66 ms |
1072 KB |
Output is correct |
24 |
Correct |
66 ms |
980 KB |
Output is correct |
25 |
Correct |
70 ms |
984 KB |
Output is correct |
26 |
Correct |
61 ms |
980 KB |
Output is correct |
27 |
Correct |
103 ms |
980 KB |
Output is correct |
28 |
Correct |
113 ms |
1064 KB |
Output is correct |
29 |
Correct |
101 ms |
1064 KB |
Output is correct |
30 |
Correct |
98 ms |
1068 KB |
Output is correct |
31 |
Correct |
96 ms |
980 KB |
Output is correct |
32 |
Correct |
122 ms |
1032 KB |
Output is correct |
33 |
Correct |
125 ms |
1036 KB |
Output is correct |
34 |
Correct |
129 ms |
980 KB |
Output is correct |
35 |
Correct |
122 ms |
1036 KB |
Output is correct |
36 |
Correct |
122 ms |
928 KB |
Output is correct |