제출 #954579

#제출 시각아이디문제언어결과실행 시간메모리
954579ezzzayTracks in the Snow (BOI13_tracks)C++14
9.90 / 100
2074 ms48036 KiB
#include<bits/stdc++.h> using namespace std; const int N=4e3+1; char a[N][N]; int xx[2]={0,1}; int yy[2]={1,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<2;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...