Submission #333517

#TimeUsernameProblemLanguageResultExecution timeMemory
333517luanaamorimTracks in the Snow (BOI13_tracks)C++14
2.19 / 100
2104 ms83648 KiB
#include <iostream> #include <queue> using namespace std; char tab[4002][4002]; int n, m, f, r, ans, passou[4002][4002], passou2[4002][4002]; queue<pair<int, int> > fila; void bfs(int a, int b) { fila.push(make_pair(a, b)); while (!fila.empty()) { int a = fila.front().first, b = fila.front().second; fila.pop(); if (a < 1 || b < 1 || a > n || b > m) continue; if (tab[a][b] == '.' || passou[a][b]) continue; r += (tab[a][b] == 'R'), f += (tab[a][b] == 'F'); passou[a][b] = 1; 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)); } } int main() { cin >> n >> m; for (int i = 1; i <= n; i++) for (int j = 1; j <= m; j++) cin >> tab[i][j]; bfs(1, 1); r = min(r, 1), f = min(f, 1); cout << r + f << endl; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...