Submission #48698

#TimeUsernameProblemLanguageResultExecution timeMemory
48698ExtazyTracks in the Snow (BOI13_tracks)C++17
15.52 / 100
2091 ms687528 KiB
#include <bits/stdc++.h> #define endl '\n' using namespace std; const int N = 4007; const pair < int, int > D[4] = { make_pair(1,0), make_pair(-1,0), make_pair(0,1), make_pair(0,-1) }; int n,m; char a[N][N]; bool used[N][N]; int ans; void clear_used() { int i,j; for(i=1;i<=n;i++) { for(j=1;j<=m;j++) { used[i][j]=false; } } } void dfs(int r, int c, char ch) { a[r][c]='#'; used[r][c]=true; int i,p,t; for(i=0;i<4;i++) { p=r+D[i].first; t=c+D[i].second; if(p>=1 && p<=n && t>=1 && t<=m) if(!used[p][t]) if(a[p][t]==ch || a[p][t]=='#') dfs(p,t,ch); } } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int i,j; scanf("%d %d", &n, &m); for(i=1;i<=n;i++) { scanf("%s", a[i]+1); } for(i=1;i<=n;i++) { for(j=1;j<=m;j++) { if(a[i][j]!='#' && a[i][j]!='.') { clear_used(); dfs(i,j,a[i][j]); ++ans; } } } printf("%d\n", ans); return 0; }

Compilation message (stderr)

tracks.cpp: In function 'int main()':
tracks.cpp:48:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d %d", &n, &m);
   ~~~~~^~~~~~~~~~~~~~~~~
tracks.cpp:50:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%s", a[i]+1);
     ~~~~~^~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...