Submission #757457

#TimeUsernameProblemLanguageResultExecution timeMemory
757457drdilyorTracks in the Snow (BOI13_tracks)C++17
2.19 / 100
874 ms747180 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; signed main() { cin.tie(0)->sync_with_stdio(0); int n, m; cin >> n >> m; vector<string> mat(n); string res; for (string& s : mat) { cin >> s; res += s; } vector vis(n, vector(m, 0)); auto dfs = [&](auto &dfs, int i, int j)-> void { if (i < 0 || i >= n || j < 0 || j >= m) return; if (vis[i][j]) return; if (mat[i][j] != mat[0][0]) return; vis[i][j] = 1; dfs(dfs, i+1, j); dfs(dfs, i-1, j); dfs(dfs, i, j+1); dfs(dfs, i, j-1); }; int r = res.find('R') != string::npos; int f = res.find('F') != string::npos; if (f&&r) { dfs(dfs, 0, 0); for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { if (!vis[i][j] && mat[i][j] == mat[0][0]) { f = 2; break; } } } } cout << r+f<< '\n'; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...