제출 #1120402

#제출 시각아이디문제언어결과실행 시간메모리
1120402coolboy19521Tracks in the Snow (BOI13_tracks)C++17
58.44 / 100
2094 ms63272 KiB
#include"bits/stdc++.h" using namespace std; const int mxN = 4003; int g[mxN][mxN]; main() { cin.tie(nullptr)->sync_with_stdio(false); int H, W; cin >> H >> W; int allemp = 1; for (int i = 0; i < H; i ++) { for (int j = 0; j < W; j ++) { char c; cin >> c; if ('R' == c) { g[i][j] = 0; } else if ('F' == c) { g[i][j] = 1; } else { g[i][j] = 2; } if ('.' != c) { allemp = 0; } } } int ans = 0; if (allemp) { cout << 0 << endl; return 0; } while (1) { ans ++; int cn[3]{}; for (int i = 0; i < H; i ++) { for (int j = 0; j < W; j ++) { cn[g[i][j]] = 1; } } if (1 >= cn[0] + cn[1]) { break; } int c = g[0][0]; g[0][0] = 1 - c; queue<pair<int,int>> q; q.emplace(0, 0); while (!q.empty()) { auto [i, j] = q.front(); q.pop(); if (i + 1 < H && c == g[i + 1][j]) { g[i + 1][j] = 1 - c; q.emplace(i + 1, j); } if (j + 1 < W && c == g[i][j + 1]) { g[i][j + 1] = 1 - c; q.emplace(i, j + 1); } if (0 <= i - 1 && c == g[i - 1][j]) { g[i - 1][j] = 1 - c; q.emplace(i - 1, j); } if (0 <= j - 1 && c == g[i][j - 1]) { g[i][j - 1] = 1 - c; q.emplace(i, j - 1); } } } cout << ans << endl; }

컴파일 시 표준 에러 (stderr) 메시지

tracks.cpp:8:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    8 | main() {
      | ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...