Submission #746789

# Submission time Handle Problem Language Result Execution time Memory
746789 2023-05-23T06:03:29 Z Github Tracks in the Snow (BOI13_tracks) C++14
31.7708 / 100
736 ms 260684 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 (nX >= 0 && nX < h && nY >= 0 && nY < w && grid[nX][nY] != '.' && 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();
      |               ^
# Verdict Execution time Memory Grader output
1 Incorrect 41 ms 81740 KB Output isn't correct
2 Correct 33 ms 79608 KB Output is correct
3 Incorrect 34 ms 79764 KB Output isn't correct
4 Incorrect 35 ms 81740 KB Output isn't correct
5 Incorrect 31 ms 80796 KB Output isn't correct
6 Correct 31 ms 79612 KB Output is correct
7 Incorrect 31 ms 79708 KB Output isn't correct
8 Incorrect 34 ms 79756 KB Output isn't correct
9 Incorrect 31 ms 79924 KB Output isn't correct
10 Incorrect 30 ms 80588 KB Output isn't correct
11 Incorrect 31 ms 80332 KB Output isn't correct
12 Incorrect 35 ms 80764 KB Output isn't correct
13 Incorrect 33 ms 80716 KB Output isn't correct
14 Incorrect 31 ms 80772 KB Output isn't correct
15 Incorrect 37 ms 81748 KB Output isn't correct
16 Incorrect 45 ms 81752 KB Output isn't correct
17 Incorrect 37 ms 81664 KB Output isn't correct
18 Incorrect 36 ms 81748 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Correct 36 ms 94892 KB Output is correct
2 Incorrect 60 ms 85024 KB Output isn't correct
3 Incorrect 65 ms 97128 KB Output isn't correct
4 Incorrect 73 ms 87788 KB Output isn't correct
5 Correct 114 ms 92812 KB Output is correct
6 Incorrect 628 ms 105428 KB Output isn't correct
7 Correct 38 ms 95564 KB Output is correct
8 Correct 36 ms 94844 KB Output is correct
9 Incorrect 31 ms 79660 KB Output isn't correct
10 Correct 31 ms 79540 KB Output is correct
11 Correct 37 ms 95284 KB Output is correct
12 Correct 34 ms 80128 KB Output is correct
13 Incorrect 60 ms 85104 KB Output isn't correct
14 Incorrect 47 ms 83616 KB Output isn't correct
15 Correct 51 ms 83916 KB Output is correct
16 Incorrect 44 ms 81276 KB Output isn't correct
17 Incorrect 74 ms 88468 KB Output isn't correct
18 Correct 81 ms 88404 KB Output is correct
19 Incorrect 73 ms 87796 KB Output isn't correct
20 Incorrect 40 ms 87256 KB Output isn't correct
21 Incorrect 48 ms 93204 KB Output isn't correct
22 Correct 114 ms 92748 KB Output is correct
23 Incorrect 57 ms 90548 KB Output isn't correct
24 Correct 115 ms 93328 KB Output is correct
25 Correct 324 ms 97224 KB Output is correct
26 Correct 548 ms 145276 KB Output is correct
27 Runtime error 736 ms 260684 KB Execution killed with signal 11
28 Incorrect 632 ms 105548 KB Output isn't correct
29 Runtime error 723 ms 210440 KB Execution killed with signal 11
30 Runtime error 729 ms 223624 KB Execution killed with signal 11
31 Incorrect 391 ms 93876 KB Output isn't correct
32 Runtime error 643 ms 222012 KB Execution killed with signal 11