Submission #900202

# Submission time Handle Problem Language Result Execution time Memory
900202 2024-01-07T21:15:29 Z aykhn Tracks in the Snow (BOI13_tracks) C++17
2.1875 / 100
826 ms 296540 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mx=4000;
char a[mx][mx];
bool vis[mx][mx];
int dist[mx][mx];
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};
int n, m;
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    memset(vis, 0, sizeof(vis));
    memset(dist, 0x3f, sizeof(dist));
    cin>>n>>m;
    for(int i=0;i<n;i++)for(int j=0;j<m;j++)cin>>a[i][j];
    deque<pair<int, int>> q;
    q.push_front({0, 0});
    dist[0][0]=1;
    int mxd=0;
    while(!q.empty()){
        auto [x, y] = q.front();
        q.pop_front();
        if(vis[x][y])continue;
        vis[x][y]=1;
        mxd=max(mxd, dist[x][y]);
        for(int i=0;i<4;i++){
            int nx = x+dx[i], ny=y+dy[i];
            if(nx<0||ny<0||nx>=n||ny>=m)continue;
            if(vis[nx][ny])continue;
            if(a[nx][ny]=='.')continue;
            if(a[nx][ny]!=a[x][y])q.push_back({nx, ny}), dist[nx][ny]=dist[x][y]+1;
            else q.push_front({nx, ny}), dist[nx][ny]=dist[x][y];
        }
    }
  	assert(mxd <= 2);
    cout<<mxd;
    return 0;
}
# Verdict Execution time Memory Grader output
1 Runtime error 95 ms 163664 KB Execution killed with signal 6
2 Runtime error 76 ms 163156 KB Execution killed with signal 6
3 Runtime error 76 ms 163024 KB Execution killed with signal 6
4 Runtime error 81 ms 164152 KB Execution killed with signal 6
5 Runtime error 77 ms 163200 KB Execution killed with signal 6
6 Runtime error 73 ms 163152 KB Execution killed with signal 6
7 Runtime error 74 ms 163160 KB Execution killed with signal 6
8 Runtime error 74 ms 163152 KB Execution killed with signal 6
9 Runtime error 74 ms 163256 KB Execution killed with signal 6
10 Runtime error 76 ms 163152 KB Execution killed with signal 6
11 Runtime error 78 ms 163412 KB Execution killed with signal 6
12 Runtime error 79 ms 163348 KB Execution killed with signal 6
13 Runtime error 75 ms 163112 KB Execution killed with signal 6
14 Runtime error 75 ms 163364 KB Execution killed with signal 6
15 Runtime error 86 ms 167592 KB Execution killed with signal 6
16 Runtime error 85 ms 163536 KB Execution killed with signal 6
17 Runtime error 81 ms 163412 KB Execution killed with signal 6
18 Runtime error 81 ms 164180 KB Execution killed with signal 6
# Verdict Execution time Memory Grader output
1 Runtime error 88 ms 189536 KB Execution killed with signal 6
2 Runtime error 115 ms 173084 KB Execution killed with signal 6
3 Runtime error 328 ms 206672 KB Execution killed with signal 6
4 Runtime error 137 ms 179324 KB Execution killed with signal 6
5 Runtime error 215 ms 192652 KB Execution killed with signal 6
6 Runtime error 826 ms 225372 KB Execution killed with signal 6
7 Runtime error 88 ms 191056 KB Execution killed with signal 6
8 Runtime error 86 ms 189496 KB Execution killed with signal 6
9 Runtime error 79 ms 163296 KB Execution killed with signal 6
10 Runtime error 73 ms 163152 KB Execution killed with signal 6
11 Runtime error 87 ms 190292 KB Execution killed with signal 6
12 Runtime error 74 ms 163152 KB Execution killed with signal 6
13 Runtime error 114 ms 173140 KB Execution killed with signal 6
14 Runtime error 102 ms 168272 KB Execution killed with signal 6
15 Runtime error 92 ms 168224 KB Execution killed with signal 6
16 Runtime error 91 ms 163924 KB Execution killed with signal 6
17 Runtime error 177 ms 179716 KB Execution killed with signal 6
18 Runtime error 142 ms 179540 KB Execution killed with signal 6
19 Runtime error 160 ms 179280 KB Execution killed with signal 6
20 Runtime error 134 ms 179024 KB Execution killed with signal 6
21 Runtime error 226 ms 193108 KB Execution killed with signal 6
22 Runtime error 224 ms 192804 KB Execution killed with signal 6
23 Runtime error 269 ms 187472 KB Execution killed with signal 6
24 Runtime error 226 ms 197260 KB Execution killed with signal 6
25 Runtime error 403 ms 206676 KB Execution killed with signal 6
26 Correct 631 ms 205440 KB Output is correct
27 Runtime error 776 ms 296540 KB Execution killed with signal 6
28 Runtime error 823 ms 225100 KB Execution killed with signal 6
29 Runtime error 822 ms 244880 KB Execution killed with signal 6
30 Runtime error 796 ms 263316 KB Execution killed with signal 6
31 Runtime error 599 ms 200220 KB Execution killed with signal 6
32 Runtime error 717 ms 247392 KB Execution killed with signal 6