제출 #954576

#제출 시각아이디문제언어결과실행 시간메모리
954576ezzzayTracks in the Snow (BOI13_tracks)C++14
13.33 / 100
2087 ms23820 KiB
#include<bits/stdc++.h> using namespace std; const int N=2e3+1; char a[N][N]; int xx[4]={0,0,1,-1}; int yy[4]={1,-1,0,0}; bool vis[N][N]; void dfs(int py, int px, char c){ a[py][px]='?'; vis[py][px]=1; for(int i=0;i<4;i++){ if((a[py+yy[i]][px+xx[i]]=='?' or a[py+yy[i]][px+xx[i]]==c) and vis[py+yy[i]][px+xx[i]]==0){ dfs(py+yy[i],px+xx[i],c); } } } signed main(){ int n,m; cin>>n>>m; for(int i=1;i<=n;i++){ for(int j=1;j<=m;j++){ cin>>a[i][j]; } } int cnt=0; for(int i=1;i<=n;i++){ for(int j=1;j<=m;j++){ if(a[i][j]=='F' or a[i][j]=='R'){ for(int x=1;x<=n;x++){ for(int y=1;y<=m;y++)vis[x][y]=0; } dfs(i,j,a[i][j]); cnt++; i=1; j=1; } } } cout<<cnt; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...