답안 #746788

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
746788 2023-05-23T06:02:36 Z Github Tracks in the Snow (BOI13_tracks) C++14
0 / 100
220 ms 216672 KB
#include <iostream>
#include <vector>
#include <set>
#include <queue>
#include <cmath>
#include <cstring>
#include <algorithm>
using namespace std;

#define speedup ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
#define ll long long
const int MAXN = 4500;

char grid[MAXN][MAXN];
int dist[MAXN][MAXN];
int dX[] = {1, -1, 0, 0};
int dY[] = {0, 0, 1, -1};
int h, w;

int main(){
    speedup
    cin >> h >> w;
    for (int i = 0; i < h; i++){
        string s; cin >> s;
        for (int j = 0; j < w; j++){
            grid[i][j] = s[j];
        }
    }
    deque<pair<int, int>> q;
    q.push_front({0, 0});
    for (int i = 0; i < MAXN; i++){
        for (int j = 0; j < MAXN; j++){
            dist[i][j] = 0;
        }
    }
    dist[0][0] = 1;
    int ans = 1;
    while (!q.empty()){
        auto &[x, y] = q.front(); q.pop_front();
        ans = max(ans, dist[x][y]);
        for (int i = 0; i < 4; i++){
            int nX = x+dX[i], nY = y+dY[i];
            if (x >= 0 && x < h && y >= 0 && y < w && grid[x][y] != '.' && dist[nX][nY] == 0){
                if (grid[nX][nY] == grid[x][y]){
                    dist[nX][nY] = dist[x][y];
                    q.push_front({nX, nY});
                }else{
                    dist[nX][nY] = dist[x][y]+1;
                    q.push_back({nX, nY});
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Compilation message

tracks.cpp: In function 'int main()':
tracks.cpp:39:15: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   39 |         auto &[x, y] = q.front(); q.pop_front();
      |               ^
# 결과 실행 시간 메모리 Grader output
1 Runtime error 102 ms 165548 KB Execution killed with signal 11
2 Runtime error 99 ms 161288 KB Execution killed with signal 11
3 Runtime error 103 ms 161468 KB Execution killed with signal 11
4 Runtime error 118 ms 165568 KB Execution killed with signal 11
5 Runtime error 111 ms 163620 KB Execution killed with signal 11
6 Runtime error 122 ms 161220 KB Execution killed with signal 11
7 Runtime error 99 ms 161460 KB Execution killed with signal 11
8 Runtime error 108 ms 161620 KB Execution killed with signal 11
9 Incorrect 33 ms 79912 KB Output isn't correct
10 Runtime error 105 ms 163292 KB Execution killed with signal 11
11 Runtime error 107 ms 162868 KB Execution killed with signal 11
12 Runtime error 111 ms 163628 KB Execution killed with signal 11
13 Runtime error 101 ms 163556 KB Execution killed with signal 11
14 Runtime error 104 ms 163644 KB Execution killed with signal 11
15 Runtime error 109 ms 165640 KB Execution killed with signal 11
16 Runtime error 105 ms 165484 KB Execution killed with signal 11
17 Runtime error 98 ms 165400 KB Execution killed with signal 11
18 Runtime error 105 ms 165580 KB Execution killed with signal 11
# 결과 실행 시간 메모리 Grader output
1 Incorrect 42 ms 94984 KB Output isn't correct
2 Incorrect 70 ms 85008 KB Output isn't correct
3 Runtime error 138 ms 196928 KB Execution killed with signal 11
4 Runtime error 111 ms 177952 KB Execution killed with signal 11
5 Incorrect 206 ms 92932 KB Output isn't correct
6 Runtime error 147 ms 196940 KB Execution killed with signal 11
7 Runtime error 121 ms 193668 KB Execution killed with signal 11
8 Incorrect 36 ms 94984 KB Output isn't correct
9 Runtime error 94 ms 161288 KB Execution killed with signal 11
10 Runtime error 103 ms 161228 KB Execution killed with signal 11
11 Incorrect 37 ms 95340 KB Output isn't correct
12 Runtime error 97 ms 162380 KB Execution killed with signal 11
13 Incorrect 71 ms 85108 KB Output isn't correct
14 Incorrect 54 ms 83680 KB Output isn't correct
15 Runtime error 104 ms 170148 KB Execution killed with signal 11
16 Runtime error 115 ms 164724 KB Execution killed with signal 11
17 Runtime error 116 ms 179152 KB Execution killed with signal 11
18 Runtime error 115 ms 179100 KB Execution killed with signal 11
19 Runtime error 121 ms 178020 KB Execution killed with signal 11
20 Runtime error 118 ms 176852 KB Execution killed with signal 11
21 Incorrect 50 ms 93308 KB Output isn't correct
22 Incorrect 196 ms 92916 KB Output isn't correct
23 Runtime error 129 ms 183500 KB Execution killed with signal 11
24 Runtime error 128 ms 188964 KB Execution killed with signal 11
25 Runtime error 152 ms 196948 KB Execution killed with signal 11
26 Runtime error 134 ms 192820 KB Execution killed with signal 11
27 Runtime error 220 ms 216672 KB Execution killed with signal 11
28 Runtime error 138 ms 196948 KB Execution killed with signal 11
29 Runtime error 139 ms 196940 KB Execution killed with signal 11
30 Runtime error 137 ms 196216 KB Execution killed with signal 11
31 Runtime error 125 ms 189776 KB Execution killed with signal 11
32 Runtime error 135 ms 196932 KB Execution killed with signal 11