제출 #676594

#제출 시각아이디문제언어결과실행 시간메모리
676594xyzxyzTracks in the Snow (BOI13_tracks)C++14
15.52 / 100
2131 ms984968 KiB
#include <bits/stdc++.h> using namespace std; int n, m; vector<vector<char>> karte; vector<vector<bool>> visited; void floodfill(int x, int y, char tier){ karte[x][y] = '#'; visited[x][y] = true; if(x+1<n && (karte[x+1][y]==tier || karte[x+1][y]=='#') && !visited[x+1][y]) floodfill(x+1, y, tier); if(x-1>=0 && (karte[x-1][y]==tier || karte[x-1][y]=='#') && !visited[x-1][y]) floodfill(x-1, y, tier); if(y+1<m && (karte[x][y+1]==tier || karte[x][y+1]=='#') && !visited[x][y+1]) floodfill(x, y+1, tier); if(y-1>=0 && (karte[x][y-1]==tier || karte[x][y-1]=='#') && !visited[x][y-1]) floodfill(x, y-1, tier); } int main() { cin >> n >> m; karte = vector<vector<char>>(n, vector<char>(m)); for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { cin >> karte[i][j]; } } /*for(vector<char> ele: karte) { for(char x: ele){ cout << x; } cout << endl; } */ int erg = 0; for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { if (karte[i][j] == 'F' || karte[i][j] == 'R') { erg++; visited = vector<vector<bool>>(n, vector<bool>(m, false)); floodfill(i, j, karte[i][j]); } } } cout << erg; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...