제출 #1120353

#제출 시각아이디문제언어결과실행 시간메모리
1120353coolboy19521Tracks in the Snow (BOI13_tracks)C++17
2.19 / 100
2095 ms63136 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;
    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;
        }
        char 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);
            }
        }
    }

    cout << ans << endl;
}

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

tracks.cpp:8:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    8 | main() {
      | ^~~~
tracks.cpp: In function 'int main()':
tracks.cpp:13:9: warning: variable 'allemp' set but not used [-Wunused-but-set-variable]
   13 |     int allemp = 1;
      |         ^~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...