제출 #867639

#제출 시각아이디문제언어결과실행 시간메모리
867639cheat_when_I_was_youngTracks in the Snow (BOI13_tracks)C++17
0 / 100
962 ms1048576 KiB
#include "bits/stdc++.h" using namespace std; void solve(); bool multitest(); int main() { ios::sync_with_stdio(false); cin.tie(nullptr); clock_t TIME = clock(); int TEST = 1; if (multitest()) cin >> TEST; while (TEST--) solve(); cerr << "\nUsed: " << clock() - TIME << " ms\n\n"; } bool multitest() { return 0; } int n, m; char a[4005][4005]; bool visited[4005][4005], F, R; void dfs(int x, int y) { if (a[x][y] == 'F') F = 1; if (a[x][y] == 'R') R = 1; visited[x][y] = 1; for (int i = max(x-1, 1); i <= min(x+1, n); ++i) for (int j = max(y-1, 1); j <= min(y+1, m); ++j) if ((i != x || j != y) && a[i][j] != '.' && !visited[i][j]) dfs(i, j); } void solve() { cin >> n >> m; for (int i = 1; i <= n; ++i) for (int j = 1; j <= m; ++j) cin >> a[i][j]; int ans = 0; for (int i = 1; i <= n; ++i) for (int j = 1; j <= m; ++j) if (a[i][j] != '.' && !visited[i][j]) { F = R = 0; dfs(i, j); ans += F + R; } cout << ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...