Submission #492124

# Submission time Handle Problem Language Result Execution time Memory
492124 2021-12-05T14:34:28 Z ToroTN Tracks in the Snow (BOI13_tracks) C++14
65 / 100
2000 ms 59752 KB
#include<bits/stdc++.h>
using namespace std;
short n,m,d[4005][4005],u,v,dx[]={1,-1,0,0},dy[]={0,0,1,-1},x,y,mx=-1;
char s[4005][4005];
priority_queue<tuple<short,short,short> > pq;
int main()
{
    scanf("%hd%hd",&n,&m);
    for(int i=1;i<=n;i++)
    {
        scanf("%s",s[i]+1);
        for(int j=1;j<=m;j++)
        {
            d[i][j]=20000;
        }
    }
    d[1][1]=1;
    pq.push({0,1,1});
    while(!pq.empty())
    {
        u=get<1>(pq.top());
        v=get<2>(pq.top());
        mx=max(mx,d[u][v]);
        pq.pop();
        for(int i=0;i<4;i++)
        {
            x=u+dx[i];
            y=v+dy[i];
            if(x>=1&&x<=n&&y>=1&&y<=m)
            {
                if(s[x][y]!='.')
                {
                    if(s[x][y]!=s[u][v])
                    {
                        if(d[u][v]+1<d[x][y])
                        {
                            d[x][y]=d[u][v]+1;
                            pq.push({-d[x][y],x,y});
                        }
                    }else
                    {
                        if(d[u][v]<d[x][y])
                        {
                            d[x][y]=d[u][v];
                            pq.push({-d[x][y],x,y});
                        }
                    }
                }
            }
        }
    }
    printf("%hd\n",mx);
}

Compilation message

tracks.cpp: In function 'int main()':
tracks.cpp:8:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    8 |     scanf("%hd%hd",&n,&m);
      |     ~~~~~^~~~~~~~~~~~~~~~
tracks.cpp:11:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   11 |         scanf("%s",s[i]+1);
      |         ~~~~~^~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 46 ms 4684 KB Output is correct
2 Correct 0 ms 460 KB Output is correct
3 Correct 1 ms 588 KB Output is correct
4 Correct 30 ms 4816 KB Output is correct
5 Correct 4 ms 2756 KB Output is correct
6 Correct 0 ms 460 KB Output is correct
7 Correct 1 ms 588 KB Output is correct
8 Correct 1 ms 716 KB Output is correct
9 Correct 1 ms 1100 KB Output is correct
10 Correct 6 ms 2380 KB Output is correct
11 Correct 7 ms 1996 KB Output is correct
12 Correct 17 ms 2764 KB Output is correct
13 Correct 4 ms 2636 KB Output is correct
14 Correct 4 ms 2636 KB Output is correct
15 Correct 36 ms 4684 KB Output is correct
16 Correct 50 ms 4684 KB Output is correct
17 Correct 21 ms 4580 KB Output is correct
18 Correct 30 ms 4772 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 14 ms 30668 KB Output is correct
2 Correct 116 ms 13296 KB Output is correct
3 Incorrect 88 ms 47316 KB Output isn't correct
4 Correct 121 ms 22456 KB Output is correct
5 Incorrect 50 ms 35548 KB Output isn't correct
6 Execution timed out 2085 ms 59672 KB Time limit exceeded
7 Correct 14 ms 32076 KB Output is correct
8 Correct 14 ms 30660 KB Output is correct
9 Correct 5 ms 460 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 15 ms 31436 KB Output is correct
12 Correct 2 ms 1484 KB Output is correct
13 Correct 120 ms 13280 KB Output is correct
14 Correct 65 ms 9304 KB Output is correct
15 Incorrect 9 ms 10060 KB Output isn't correct
16 Correct 59 ms 4684 KB Output is correct
17 Correct 287 ms 24012 KB Output is correct
18 Incorrect 25 ms 23756 KB Output isn't correct
19 Correct 121 ms 22444 KB Output is correct
20 Incorrect 35 ms 20884 KB Output isn't correct
21 Incorrect 60 ms 36692 KB Output isn't correct
22 Incorrect 46 ms 35552 KB Output isn't correct
23 Correct 565 ms 29708 KB Output is correct
24 Incorrect 48 ms 36848 KB Output isn't correct
25 Incorrect 78 ms 47240 KB Output isn't correct
26 Correct 1501 ms 41528 KB Output is correct
27 Execution timed out 2093 ms 49068 KB Time limit exceeded
28 Execution timed out 2097 ms 59752 KB Time limit exceeded
29 Execution timed out 2089 ms 53636 KB Time limit exceeded
30 Execution timed out 2083 ms 52540 KB Time limit exceeded
31 Execution timed out 2080 ms 38404 KB Time limit exceeded
32 Execution timed out 2062 ms 48288 KB Time limit exceeded