Submission #1043578

#TimeUsernameProblemLanguageResultExecution timeMemory
1043578KarolZNautilus (BOI19_nautilus)C++14
66 / 100
1032 ms4700 KiB
#include<iostream> #include<queue> #include<tuple> using namespace std; char a[510][510]; string s; int poz[250]; int m,r,c; pair<int,int>p[4]={{-1,0},{0,1},{1,0},{0,-1}}; int czy_odw[510][510]; queue< pair< pair<int,int>,int> >q; int suck_int(){ int wyn=0; char c=getchar_unlocked(); while(c>='0'&&c<='9'){ wyn=wyn*10+c-'0'; c=getchar_unlocked(); } return wyn; } int beefes(){ pair<int,int>xy; int wyn=0; int kt; while(!q.empty()){ tie(xy,kt)=q.front(); q.pop(); // cout<<kt<<' '; if(kt==m){ wyn++; // a[xy.first][xy.second]='X'; continue; } if(s[kt]=='?'){ for(int i=0;i<4;i++){ if(czy_odw[xy.first+p[i].first][xy.second+p[i].second]<kt+1&&a[xy.first+p[i].first][xy.second+p[i].second]=='.'){ q.push({{xy.first+p[i].first,xy.second+p[i].second},kt+1}); czy_odw[xy.first+p[i].first][xy.second+p[i].second]=kt+1; } } } else{ // cout<<kt<<' '<<xy.first<<' '<<xy.second<<'\n'; if(czy_odw[xy.first+p[poz[s[kt]]].first][xy.second+p[poz[s[kt]]].second]<kt+1&&a[xy.first+p[poz[s[kt]]].first][xy.second+p[poz[s[kt]]].second]=='.'){ // cout<<kt<<' '<<xy.first<<' '<<xy.second<<'\n'; q.push({{xy.first+p[poz[s[kt]]].first,xy.second+p[poz[s[kt]]].second},kt+1}); czy_odw[xy.first+p[poz[s[kt]]].first][xy.second+p[poz[s[kt]]].second]=kt+1; } } } /*for(int i=0;i<=r+1;i++){ for(int j=0;j<=c+1;j++)cout<<a[i][j]; cout<<'\n'; }*/ return wyn; } int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); //cin>>r>>c>>m; r=suck_int(); c=suck_int(); m=suck_int(); poz['N']=0; poz['E']=1; poz['S']=2; poz['W']=3; for(int i=0;i<=r+1;i++){ for(int j=0;j<=c+1;j++){ if(i>0&&i<=r&&j>0&&j<=c)a[i][j]=getchar_unlocked(); else a[i][j]='#'; if(a[i][j]=='.')q.push({{i,j},0}); } if(i>0&&i<=r)getchar_unlocked(); } s=""; for(int i=0;i<m;i++)s+=getchar_unlocked(); cout<<beefes(); return 0; }

Compilation message (stderr)

nautilus.cpp: In function 'int beefes()':
nautilus.cpp:44:35: warning: array subscript has type 'char' [-Wchar-subscripts]
   44 |    if(czy_odw[xy.first+p[poz[s[kt]]].first][xy.second+p[poz[s[kt]]].second]<kt+1&&a[xy.first+p[poz[s[kt]]].first][xy.second+p[poz[s[kt]]].second]=='.'){
      |                                   ^
nautilus.cpp:44:66: warning: array subscript has type 'char' [-Wchar-subscripts]
   44 |    if(czy_odw[xy.first+p[poz[s[kt]]].first][xy.second+p[poz[s[kt]]].second]<kt+1&&a[xy.first+p[poz[s[kt]]].first][xy.second+p[poz[s[kt]]].second]=='.'){
      |                                                                  ^
nautilus.cpp:44:105: warning: array subscript has type 'char' [-Wchar-subscripts]
   44 |    if(czy_odw[xy.first+p[poz[s[kt]]].first][xy.second+p[poz[s[kt]]].second]<kt+1&&a[xy.first+p[poz[s[kt]]].first][xy.second+p[poz[s[kt]]].second]=='.'){
      |                                                                                                         ^
nautilus.cpp:44:136: warning: array subscript has type 'char' [-Wchar-subscripts]
   44 |    if(czy_odw[xy.first+p[poz[s[kt]]].first][xy.second+p[poz[s[kt]]].second]<kt+1&&a[xy.first+p[poz[s[kt]]].first][xy.second+p[poz[s[kt]]].second]=='.'){
      |                                                                                                                                        ^
nautilus.cpp:46:34: warning: array subscript has type 'char' [-Wchar-subscripts]
   46 |     q.push({{xy.first+p[poz[s[kt]]].first,xy.second+p[poz[s[kt]]].second},kt+1});
      |                                  ^
nautilus.cpp:46:64: warning: array subscript has type 'char' [-Wchar-subscripts]
   46 |     q.push({{xy.first+p[poz[s[kt]]].first,xy.second+p[poz[s[kt]]].second},kt+1});
      |                                                                ^
nautilus.cpp:47:33: warning: array subscript has type 'char' [-Wchar-subscripts]
   47 |     czy_odw[xy.first+p[poz[s[kt]]].first][xy.second+p[poz[s[kt]]].second]=kt+1;
      |                                 ^
nautilus.cpp:47:64: warning: array subscript has type 'char' [-Wchar-subscripts]
   47 |     czy_odw[xy.first+p[poz[s[kt]]].first][xy.second+p[poz[s[kt]]].second]=kt+1;
      |                                                                ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...