Submission #862595

# Submission time Handle Problem Language Result Execution time Memory
862595 2023-10-18T15:10:02 Z neodoomer Tracks in the Snow (BOI13_tracks) C++14
0 / 100
1664 ms 1048576 KB
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define F first
#define S second
#define pi pair<int,int>
const int N=4010;
vector<pair<pi,int> >adj[N][N];
int n,m,vis[N][N],ans;
char g[N][N];
int dx[]={0,0,-1,1};
int dy[]={-1,1,0,0};
bool good (int i,int j)
{
    return (i>-1 && j>-1 && i<n && j<m && g[i][j]!='.');
}
int main()
{

    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    cin>>n>>m;
    for(int i=0;i<n;i++)
        for(int j=0;j<m;j++)
            cin>>g[i][j];
    memset(vis,-1,sizeof vis);
    for(int i=0;i<n;i++)
        for(int j=0;j<m;j++)
            if(good(i,j))
            for(int d=0;d<4;d++)
            {
                int ni=i+dx[d],nj=j+dy[d];
                if(good(ni,nj))
                    adj[i][j].pb({{ni,nj},(g[i][j]!=g[ni][nj])});
            }
    deque<pi> dq;
    dq.pb({0,0});vis[0][0]=0;
    while(!dq.empty()){
        int i=dq.front().F,j=dq.front().S;
        dq.pop_front();
        for(auto p:adj[i][j])
        {
            int ni=p.F.F,nj=p.F.S,w=p.S;
            if(vis[ni][nj]!=-1)continue;
            vis[ni][nj]=w+vis[i][j];
            ans=max(ans,vis[ni][nj]);
            if(w)dq.pb({ni,nj});
            else dq.push_front({ni,nj});
        }
    }
    cout<<ans;

    return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 127 ms 459092 KB Output isn't correct
2 Incorrect 85 ms 442208 KB Output isn't correct
3 Incorrect 85 ms 444248 KB Output isn't correct
4 Incorrect 114 ms 454260 KB Output isn't correct
5 Incorrect 89 ms 445268 KB Output isn't correct
6 Incorrect 85 ms 442260 KB Output isn't correct
7 Incorrect 88 ms 444384 KB Output isn't correct
8 Incorrect 90 ms 445008 KB Output isn't correct
9 Incorrect 87 ms 444428 KB Output isn't correct
10 Incorrect 93 ms 445824 KB Output isn't correct
11 Incorrect 93 ms 446796 KB Output isn't correct
12 Incorrect 99 ms 449460 KB Output isn't correct
13 Incorrect 92 ms 445396 KB Output isn't correct
14 Incorrect 90 ms 445148 KB Output isn't correct
15 Incorrect 117 ms 455508 KB Output isn't correct
16 Incorrect 129 ms 459088 KB Output isn't correct
17 Incorrect 107 ms 450388 KB Output isn't correct
18 Incorrect 112 ms 454224 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 90 ms 457040 KB Output isn't correct
2 Incorrect 206 ms 486228 KB Output isn't correct
3 Incorrect 769 ms 658568 KB Output isn't correct
4 Incorrect 246 ms 476980 KB Output isn't correct
5 Incorrect 624 ms 604116 KB Output isn't correct
6 Runtime error 1287 ms 1048576 KB Execution killed with signal 9
7 Incorrect 89 ms 457112 KB Output isn't correct
8 Incorrect 90 ms 457044 KB Output isn't correct
9 Incorrect 93 ms 443984 KB Output isn't correct
10 Incorrect 86 ms 442452 KB Output isn't correct
11 Incorrect 88 ms 456788 KB Output isn't correct
12 Incorrect 88 ms 444652 KB Output isn't correct
13 Incorrect 210 ms 485804 KB Output isn't correct
14 Incorrect 155 ms 468420 KB Output isn't correct
15 Incorrect 150 ms 456020 KB Output isn't correct
16 Incorrect 150 ms 465396 KB Output isn't correct
17 Incorrect 390 ms 543632 KB Output isn't correct
18 Incorrect 337 ms 487492 KB Output isn't correct
19 Incorrect 242 ms 475508 KB Output isn't correct
20 Incorrect 236 ms 496676 KB Output isn't correct
21 Incorrect 465 ms 575276 KB Output isn't correct
22 Incorrect 625 ms 604496 KB Output isn't correct
23 Incorrect 676 ms 637268 KB Output isn't correct
24 Incorrect 481 ms 557656 KB Output isn't correct
25 Incorrect 1664 ms 615396 KB Output isn't correct
26 Runtime error 1259 ms 1048576 KB Execution killed with signal 9
27 Runtime error 1295 ms 1048576 KB Execution killed with signal 9
28 Runtime error 1304 ms 1048576 KB Execution killed with signal 9
29 Runtime error 1296 ms 1048576 KB Execution killed with signal 9
30 Runtime error 1302 ms 1048576 KB Execution killed with signal 9
31 Runtime error 1272 ms 1048576 KB Execution killed with signal 9
32 Runtime error 1313 ms 1048576 KB Execution killed with signal 9