Submission #43409

# Submission time Handle Problem Language Result Execution time Memory
43409 2018-03-15T20:38:52 Z XmtosX 007 (CEOI14_007) C++14
6 / 100
602 ms 19032 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]-1);
    }
    lvl[a][1]++;
    lvl[b][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 Correct 7 ms 7288 KB Output is correct
2 Partially correct 6 ms 7392 KB Partially correct
3 Partially correct 7 ms 7468 KB Partially correct
4 Correct 7 ms 7608 KB Output is correct
5 Correct 7 ms 7608 KB Output is correct
6 Partially correct 7 ms 7608 KB Partially correct
7 Partially correct 7 ms 7608 KB Partially correct
8 Correct 8 ms 7608 KB Output is correct
9 Partially correct 7 ms 7608 KB Partially correct
10 Correct 7 ms 7608 KB Output is correct
11 Correct 7 ms 7708 KB Output is correct
12 Correct 8 ms 7708 KB Output is correct
13 Partially correct 7 ms 7708 KB Partially correct
14 Correct 7 ms 7708 KB Output is correct
15 Partially correct 7 ms 7708 KB Partially correct
16 Correct 7 ms 7708 KB Output is correct
17 Correct 8 ms 7708 KB Output is correct
18 Correct 7 ms 7708 KB Output is correct
19 Partially correct 7 ms 7708 KB Partially correct
20 Partially correct 7 ms 7708 KB Partially correct
21 Incorrect 7 ms 7708 KB Output isn't correct
22 Partially correct 7 ms 7708 KB Partially correct
23 Partially correct 7 ms 7708 KB Partially correct
24 Correct 8 ms 7708 KB Output is correct
# Verdict Execution time Memory Grader output
1 Partially correct 56 ms 9324 KB Partially correct
2 Correct 69 ms 9968 KB Output is correct
3 Partially correct 51 ms 9968 KB Partially correct
4 Correct 66 ms 10092 KB Output is correct
5 Incorrect 59 ms 10092 KB Output isn't correct
6 Incorrect 49 ms 10092 KB Output isn't correct
7 Partially correct 53 ms 10092 KB Partially correct
8 Partially correct 54 ms 10092 KB Partially correct
9 Correct 87 ms 10092 KB Output is correct
10 Partially correct 393 ms 14548 KB Partially correct
11 Correct 106 ms 14548 KB Output is correct
12 Partially correct 129 ms 14548 KB Partially correct
13 Correct 114 ms 14548 KB Output is correct
14 Correct 90 ms 14548 KB Output is correct
15 Partially correct 123 ms 14548 KB Partially correct
16 Incorrect 130 ms 14548 KB Output isn't correct
17 Partially correct 115 ms 14548 KB Partially correct
18 Correct 117 ms 14548 KB Output is correct
19 Partially correct 220 ms 14548 KB Partially correct
20 Correct 414 ms 16104 KB Output is correct
21 Correct 168 ms 16104 KB Output is correct
22 Partially correct 167 ms 16104 KB Partially correct
23 Partially correct 197 ms 16104 KB Partially correct
24 Partially correct 164 ms 16104 KB Partially correct
25 Correct 164 ms 16104 KB Output is correct
26 Partially correct 151 ms 16104 KB Partially correct
27 Partially correct 170 ms 16104 KB Partially correct
28 Partially correct 193 ms 16104 KB Partially correct
29 Partially correct 300 ms 16104 KB Partially correct
30 Correct 460 ms 16460 KB Output is correct
31 Correct 213 ms 16460 KB Output is correct
32 Partially correct 207 ms 16460 KB Partially correct
33 Partially correct 207 ms 16460 KB Partially correct
34 Correct 220 ms 16460 KB Output is correct
35 Correct 229 ms 16460 KB Output is correct
36 Correct 192 ms 16460 KB Output is correct
37 Incorrect 234 ms 16460 KB Output isn't correct
38 Partially correct 273 ms 16460 KB Partially correct
39 Partially correct 305 ms 16460 KB Partially correct
40 Correct 505 ms 16856 KB Output is correct
41 Partially correct 602 ms 19032 KB Partially correct