Submission #101469

#TimeUsernameProblemLanguageResultExecution timeMemory
101469rainyTracks in the Snow (BOI13_tracks)C++14
2.19 / 100
2140 ms1049600 KiB
#include<cstdio> #include<cstring> #include<algorithm> #include<vector> #include<utility> #include<queue> #define INF 1000000000 using namespace std; typedef vector<short> vi; typedef pair<int,int>ii; int H,W; char X; int dx[]={0,1,0,-1},dy[]={1,0,-1,0}; int tis(vector<vi> x, int ani){ queue<ii>q;q.push(ii(0,0)); x[0][0]=-1; bool vis[H+5][W+5]={false}; vis[0][0]=true; while(!q.empty()){ int x1=q.front().first,y1=q.front().second; q.pop(); for(int k=0;k<4;k++){ int nx=x1+dx[k],ny=y1+dy[k]; if(0<=nx&&nx<H&&0<=ny&&ny<W){ if(!vis[nx][ny]){ if(x[nx][ny]==-1||x[nx][ny]==ani){ vis[nx][ny]=true; x[nx][ny]=-1; q.push(ii(nx,ny)); } } } } } if(!vis[H-1][W-1])return INF; bool isDone=true; for(int i=0;i<H;i++){ for(int j=0;j<W;j++){ if(x[i][j]==1||x[i][j]==2){ isDone=false;break; } } if(isDone)break; } if(isDone)return 0; return 1+min(tis(x,1),tis(x,2)); } int main(){ scanf("%d%d",&H,&W); vector<vi> gr(H); for(int i=0;i<H;i++){ vi xyz(W); for(int j=0;j<W;j++){ xyz[j]=-1; } gr[i]=xyz; } for(int i=0;i<H;i++){ for(int j=0;j<W;j++){ scanf(" %c",&X); if(X=='.')gr[i][j]=0; if(X=='F')gr[i][j]=1; if(X=='R')gr[i][j]=2; } } /* for(int i=0;i<H;i++){ for(int j=0;j<W;j++){ printf("%d",gr[i][j]); } printf("\n"); } */ printf("%d\n",1+tis(gr,gr[0][0])); return 0; }

Compilation message (stderr)

tracks.cpp: In function 'int main()':
tracks.cpp:51:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d",&H,&W);
     ~~~~~^~~~~~~~~~~~~~
tracks.cpp:62:18: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
             scanf(" %c",&X);
             ~~~~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...