This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 (stderr)
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++){
| ~^~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |