Submission #43406

# Submission time Handle Problem Language Result Execution time Memory
43406 2018-03-15T20:34:27 Z XmtosX 007 (CEOI14_007) C++14
0 / 100
575 ms 19052 KB
#include <bits/stdc++.h>
using namespace std;
int n,m,st1,st2,a,b;
vector <int> v[300005];
int lvl[300005][2];
void bs (int x,int y)
{
    queue<int> q;
    lvl[x][y]=1;
    q.push(x);
    while (!q.empty())
    {
        int node=q.front();
        q.pop();
        for (int i=0;i<v[node].size();i++)
        {
            if (!lvl[v[node][i]][y])
            {
                lvl[v[node][i]][y]=lvl[node][y]+1;
                q.push(v[node][i]);
            }
        }
    }
}
int main()
{
    cin >>n>>m>>st1>>st2>>a>>b;
    for (int i=0;i<m;i++)
    {
        int x,y;
        cin >>x>>y;
        v[x].push_back(y);
        v[y].push_back(x);
    }
    bs(st1,1);
    bs(st2,0);
    vector <int> v1;
    for (int i=0;i<v[a].size();i++)
    {
        if (v[a][i]!=b&&lvl[v[a][i]][0]<lvl[a][0])
            v1.push_back(v[a][i]);
    }
    for (int i=0;i<v[b].size();i++)
    {
        if (v[b][i]!=a&&lvl[v[b][i]][0]<lvl[b][0])
            v1.push_back(v[b][i]);
    }
    int ans=-1;
    for (int i=0;i<v1.size();i++)
    {
        ans=max(ans,lvl[v1[i]][0]-lvl[v1[i]][1]);
    }
    ans=max(ans,lvl[a][0]-lvl[a][1]);
    ans=max(ans,lvl[b][0]-lvl[b][1]);
    cout <<ans;
    return 0;
}

Compilation message

007.cpp: In function 'void bs(int, int)':
007.cpp:15:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for (int i=0;i<v[node].size();i++)
                       ^
007.cpp: In function 'int main()':
007.cpp:38:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (int i=0;i<v[a].size();i++)
                   ^
007.cpp:43:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (int i=0;i<v[b].size();i++)
                   ^
007.cpp:49:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (int i=0;i<v1.size();i++)
                   ^
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 7288 KB Output isn't correct
2 Correct 6 ms 7520 KB Output is correct
3 Correct 6 ms 7520 KB Output is correct
4 Incorrect 6 ms 7536 KB Output isn't correct
5 Incorrect 6 ms 7536 KB Output isn't correct
6 Correct 6 ms 7536 KB Output is correct
7 Correct 6 ms 7592 KB Output is correct
8 Incorrect 6 ms 7712 KB Output isn't correct
9 Correct 6 ms 7712 KB Output is correct
10 Incorrect 6 ms 7712 KB Output isn't correct
11 Incorrect 6 ms 7712 KB Output isn't correct
12 Incorrect 6 ms 7712 KB Output isn't correct
13 Correct 7 ms 7712 KB Output is correct
14 Incorrect 7 ms 7712 KB Output isn't correct
15 Correct 7 ms 7712 KB Output is correct
16 Incorrect 7 ms 7712 KB Output isn't correct
17 Incorrect 7 ms 7712 KB Output isn't correct
18 Incorrect 7 ms 7712 KB Output isn't correct
19 Correct 7 ms 7712 KB Output is correct
20 Correct 7 ms 7712 KB Output is correct
21 Incorrect 9 ms 7712 KB Output isn't correct
22 Correct 8 ms 7712 KB Output is correct
23 Correct 7 ms 7712 KB Output is correct
24 Incorrect 7 ms 7712 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Correct 47 ms 9300 KB Output is correct
2 Incorrect 64 ms 9936 KB Output isn't correct
3 Correct 55 ms 9936 KB Output is correct
4 Incorrect 71 ms 9964 KB Output isn't correct
5 Incorrect 51 ms 9964 KB Output isn't correct
6 Incorrect 72 ms 9964 KB Output isn't correct
7 Correct 52 ms 9964 KB Output is correct
8 Correct 58 ms 9964 KB Output is correct
9 Incorrect 87 ms 10000 KB Output isn't correct
10 Correct 381 ms 14268 KB Output is correct
11 Incorrect 103 ms 14268 KB Output isn't correct
12 Correct 148 ms 14268 KB Output is correct
13 Incorrect 113 ms 14268 KB Output isn't correct
14 Correct 120 ms 14268 KB Output is correct
15 Correct 138 ms 14268 KB Output is correct
16 Incorrect 138 ms 14268 KB Output isn't correct
17 Correct 115 ms 14268 KB Output is correct
18 Incorrect 157 ms 14268 KB Output isn't correct
19 Correct 214 ms 14268 KB Output is correct
20 Incorrect 414 ms 16064 KB Output isn't correct
21 Incorrect 195 ms 16064 KB Output isn't correct
22 Correct 171 ms 16064 KB Output is correct
23 Correct 176 ms 16064 KB Output is correct
24 Correct 177 ms 16064 KB Output is correct
25 Incorrect 173 ms 16064 KB Output isn't correct
26 Correct 165 ms 16064 KB Output is correct
27 Correct 182 ms 16064 KB Output is correct
28 Correct 194 ms 16064 KB Output is correct
29 Correct 304 ms 16064 KB Output is correct
30 Incorrect 471 ms 16656 KB Output isn't correct
31 Incorrect 201 ms 16656 KB Output isn't correct
32 Correct 202 ms 16656 KB Output is correct
33 Correct 179 ms 16656 KB Output is correct
34 Incorrect 216 ms 16656 KB Output isn't correct
35 Incorrect 195 ms 16656 KB Output isn't correct
36 Incorrect 199 ms 16656 KB Output isn't correct
37 Incorrect 276 ms 16656 KB Output isn't correct
38 Correct 245 ms 16656 KB Output is correct
39 Correct 279 ms 16656 KB Output is correct
40 Incorrect 385 ms 16712 KB Output isn't correct
41 Correct 575 ms 19052 KB Output is correct