Submission #333341

#TimeUsernameProblemLanguageResultExecution timeMemory
333341luanaamorimTracks in the Snow (BOI13_tracks)C++14
2.19 / 100
2093 ms31852 KiB
#include <iostream> #include <queue> using namespace std; char tab[4000][4000]; int n, m, f, r, ans; queue<pair<int, int> > fila; int main() { cin >> n >> m; for (int i = 0; i < n; i++) for (int j = 0; j < m; j++) cin >> tab[i][j]; for (int i = 0; i < n; i++) for (int j = 0; j < m; j++) { if (tab[i][j] != '.') { f = 0, r = 0; fila.push(make_pair(i, j)); while (!fila.empty()) { int a = fila.front().first, b = fila.front().second; fila.pop(); if (a < 0 || b < 0 || a > n - 1 || b > m - 1) continue; if (tab[a][b] == '.') continue; else if (tab[a][b] == 'R') r = 1; else f = 1; tab[a][b] = '.'; fila.push(make_pair(a + 1, b)); fila.push(make_pair(a - 1, b)); fila.push(make_pair(a, b + 1)); fila.push(make_pair(a, b - 1)); } ans += f + r; } } cout << ans << endl; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...