#include <bits/stdc++.h>
using namespace std;
const int MAXN = 507;
bitset<MAXN> st[MAXN],bs[MAXN],xd[MAXN],tmp,tmp1,tmp2,tmp3;
int main(){
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int r,c,m,ans=0; char zn; string s;
cin>>r>>c>>m;
for(int i=1;i<=r;i++){
for(int j=0;j<c;j++){
cin>>zn;
if(zn=='.') bs[i][j]=st[i][j]=1;
}
}
cin>>s; s="#"+s;
for(int i=1;i<s.size();i++){
for(int j=1;j<=r;j++){
if(s[i]=='?'){
tmp=(bs[j+1]|bs[j-1]);
tmp1=(bs[j]<<1);
tmp2=(bs[j]>>1);
tmp3=tmp1|tmp2;
xd[j]=tmp3|tmp;
}
else if(s[i]=='N') xd[j]=bs[j+1];
else if(s[i]=='S') xd[j]=(bs[j-1]);
else if(s[i]=='E') xd[j]=(bs[j]<<1);
else xd[j]=(bs[j]>>1);
}
for(int j=1;j<=r;j++){
bs[j]=(xd[j]&st[j]);
}
}
for(int i=1;i<=r;i++) ans+=bs[i].count();
cout<<ans<<'\n';
return 0;
}
Compilation message
nautilus.cpp: In function 'int main()':
nautilus.cpp:16:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
16 | for(int i=1;i<s.size();i++){
| ~^~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
488 KB |
Output is correct |
5 |
Correct |
1 ms |
344 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
488 KB |
Output is correct |
5 |
Correct |
1 ms |
344 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
392 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 |
600 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 |
468 KB |
Output is correct |
21 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
488 KB |
Output is correct |
5 |
Correct |
1 ms |
344 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
392 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 |
600 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 |
468 KB |
Output is correct |
21 |
Correct |
1 ms |
348 KB |
Output is correct |
22 |
Correct |
74 ms |
604 KB |
Output is correct |
23 |
Correct |
75 ms |
796 KB |
Output is correct |
24 |
Correct |
72 ms |
792 KB |
Output is correct |
25 |
Correct |
72 ms |
604 KB |
Output is correct |
26 |
Correct |
70 ms |
604 KB |
Output is correct |
27 |
Correct |
111 ms |
792 KB |
Output is correct |
28 |
Correct |
115 ms |
856 KB |
Output is correct |
29 |
Correct |
112 ms |
604 KB |
Output is correct |
30 |
Correct |
112 ms |
600 KB |
Output is correct |
31 |
Correct |
111 ms |
776 KB |
Output is correct |
32 |
Correct |
146 ms |
852 KB |
Output is correct |
33 |
Correct |
142 ms |
600 KB |
Output is correct |
34 |
Correct |
146 ms |
604 KB |
Output is correct |
35 |
Correct |
142 ms |
792 KB |
Output is correct |
36 |
Correct |
142 ms |
600 KB |
Output is correct |