Submission #101838

#TimeUsernameProblemLanguageResultExecution timeMemory
101838rainyTracks in the Snow (BOI13_tracks)C++14
21.67 / 100
2102 ms299684 KiB
#include<cstdio> #include<cstring> #include<algorithm> using namespace std; int H,W; char gr[4005][4005],ca,idk='a'; int vis[4005][4005]; int dx[]={0,1,0,-1},dy[]={1,0,-1,0}; void dfs(int x,int y){ for(int i=0;i<4;i++){ int nx=x+dx[i],ny=y+dy[i]; if(0<=nx&&nx<H&&0<=ny&&ny<W){ if(!vis[nx][ny]&&(gr[nx][ny]==ca||gr[nx][ny]==idk)){ vis[nx][ny]=1; gr[nx][ny]=idk; dfs(nx,ny); } } } } int main(){ scanf("%d%d",&H,&W); for(int i=0;i<H;i++){ for(int j=0;j<W;j++)scanf(" %c",&gr[i][j]); } ca=gr[0][0]; int ans=0; while(true){ ans++; memset(vis,0,sizeof(vis)); dfs(0,0); if(ca=='F')ca='R'; else ca='F'; bool isD=true; for(int i=0;i<H;i++){ for(int j=0;j<W;j++){ if(gr[i][j]=='F'||gr[i][j]=='R')isD=false; } } if(isD)break; } printf("%d\n",ans); return 0; }

Compilation message (stderr)

tracks.cpp: In function 'int main()':
tracks.cpp:24: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:26:34: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         for(int j=0;j<W;j++)scanf(" %c",&gr[i][j]);
                             ~~~~~^~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...