Submission #42406

#TimeUsernameProblemLanguageResultExecution timeMemory
42406HassoonyTracks in the Snow (BOI13_tracks)C++14
36.56 / 100
2151 ms1048576 KiB
#include<bits/stdc++.h> #include<unordered_map> #define F first #define S second using namespace std; typedef long long ll; typedef long double D; const ll inf=(1ll<<61); const ll mod=1e9+7; const int MX=4002; int n,m,cnt,h; bool vis[MX][MX]; char a[MX][MX],c; int dx[]={0,0,-1,1}; int dy[]={1,-1,0,0}; vector<pair<int,int> >nodes; void dfs(int x,int y){ if(vis[x][y])return; vis[x][y]=1; cnt++; nodes.push_back({x,y}); for(int i=0;i<4;i++){ int nx=dx[i]+x,ny=dy[i]+y; if(nx>=n||ny>=m||nx<0||ny<0||a[nx][ny]!=a[x][y])continue; dfs(nx,ny); } a[x][y]=c; } int main(){ scanf("%d%d",&n,&m); for(int i=0;i<n;i++)scanf("%s",&a[i]); for(int i=0;i<n;i++){ for(int j=0;j<m;j++){ if(a[i][j]!='.')h++; } } int ans=0; while(cnt!=h){ c='R'; if(a[0][0]=='R')c='F'; cnt=0; dfs(0,0); ans++; for(auto pp:nodes)vis[pp.first][pp.second]=0; nodes.clear(); } cout<<ans<<endl; }

Compilation message (stderr)

tracks.cpp: In function 'int main()':
tracks.cpp:31:41: warning: format '%s' expects argument of type 'char*', but argument 2 has type 'char (*)[4002]' [-Wformat=]
     for(int i=0;i<n;i++)scanf("%s",&a[i]);
                                         ^
tracks.cpp:30:24: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d",&n,&m);
                        ^
tracks.cpp:31:42: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for(int i=0;i<n;i++)scanf("%s",&a[i]);
                                          ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...