제출 #969967

#제출 시각아이디문제언어결과실행 시간메모리
969967AiperiiiNautilus (BOI19_nautilus)C++14
29 / 100
482 ms262144 KiB
#include <bits/stdc++.h> #define int long long #define ff first #define ss second #define pb push_back #define all(x) x.begin(),x.end() using namespace std; const int N=105; char a[N][N]; signed main(){ ios_base::sync_with_stdio(); cin.tie(0);cout.tie(0); int n,m,k; cin>>n>>m>>k; for(int i=0;i<n;i++){ for(int j=0;j<m;j++){ cin>>a[i][j]; } } string s;cin>>s; set <pair <int,int> > st; for(int i=0;i<n;i++){ for(int j=0;j<m;j++){ if(a[i][j]=='#')continue; queue <vector <int> > q; q.push({i,j,-1}); while(!q.empty()){ int x=q.front()[0]; int y=q.front()[1]; int ind=q.front()[2]; q.pop(); ind++; if(ind==k){ st.insert({x,y}); continue; } if(s[ind]=='W' && y-1>=0 && a[x][y-1]=='.')q.push({x,y-1,ind}); if(s[ind]=='E' && y+1<m && a[x][y+1]=='.')q.push({x,y+1,ind}); if(s[ind]=='S' && x+1<n && a[x+1][y]=='.')q.push({x+1,y,ind}); if(s[ind]=='N' && x-1>=0 && a[x-1][y]=='.')q.push({x-1,y,ind}); if(s[ind]=='?'){ if(y-1>=0 && a[x][y-1]=='.')q.push({x,y-1,ind}); if(y+1<m && a[x][y+1]=='.')q.push({x,y+1,ind}); if(x-1>=0 && a[x-1][y]=='.')q.push({x-1,y,ind}); if(x+1<n && a[x+1][y]=='.')q.push({x+1,y,ind}); } } } } cout<<st.size()<<"\n"; } /* 5 9 7 ...##.... ..#.##..# ..#....## .##...#.. ....#.... WS?EE?? */
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...