Submission #90664

# Submission time Handle Problem Language Result Execution time Memory
90664 2018-12-23T10:45:32 Z 314rate 007 (CEOI14_007) C++14
30 / 100
605 ms 73212 KB
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;

const int N=2000000+5;

int n;
int m;
int s,d,a,b;

int di[2][N];

vector<int>g[N];

void build(int k,int go)
{
    for(int j=0;j<N;j++)
    {
        di[k][j]=-1;
    }
    di[k][go]=0;
    queue<int>q;
    q.push(go);
    while(!q.empty())
    {
        int nod=q.front();
        q.pop();
        for(auto &nou:g[nod])
        {
            if(di[k][nou]==-1)
            {
                di[k][nou]=1+di[k][nod];
                q.push(nou);
            }
        }
    }
}

int main()
{
   // freopen("input","r",stdin);
   // freopen("output","w",stdout);
    cin>>n>>m;
    cin>>s>>d>>a>>b;
    for(int i=1;i<=m;i++)
    {
        int x,y;
        cin>>x>>y;
        g[x].push_back(y);
        g[y].push_back(x);
    }
    build(0,s);
    build(1,d);
    int a1=di[0][a],a2=di[0][b];
    int b1=di[1][a],b2=di[1][b];
    int x1=b1-a1;
    int x2=b2-a2;
    int ans;
    if(x1!=x2)
    {
        ans=min(x1,x2);
    }
    else
    {
        ans=x1-1;
    }
    if(ans<-1)
    {
        ans=-1;
    }
    cout<<ans<<"\n";
    return 0;
}
/**


**/
# Verdict Execution time Memory Grader output
1 Correct 56 ms 62968 KB Output is correct
2 Partially correct 58 ms 62968 KB Partially correct
3 Partially correct 56 ms 63000 KB Partially correct
4 Correct 58 ms 63012 KB Output is correct
5 Correct 57 ms 63248 KB Output is correct
6 Partially correct 56 ms 63248 KB Partially correct
7 Partially correct 58 ms 63248 KB Partially correct
8 Correct 52 ms 63248 KB Output is correct
9 Partially correct 49 ms 63248 KB Partially correct
10 Correct 49 ms 63248 KB Output is correct
11 Correct 50 ms 63248 KB Output is correct
12 Correct 48 ms 63248 KB Output is correct
13 Partially correct 49 ms 63248 KB Partially correct
14 Correct 50 ms 63248 KB Output is correct
15 Partially correct 48 ms 63248 KB Partially correct
16 Correct 48 ms 63248 KB Output is correct
17 Correct 48 ms 63248 KB Output is correct
18 Correct 57 ms 63248 KB Output is correct
19 Partially correct 48 ms 63248 KB Partially correct
20 Partially correct 59 ms 63248 KB Partially correct
21 Correct 49 ms 63248 KB Output is correct
22 Partially correct 59 ms 63248 KB Partially correct
23 Partially correct 49 ms 63248 KB Partially correct
24 Correct 57 ms 63248 KB Output is correct
# Verdict Execution time Memory Grader output
1 Partially correct 81 ms 64508 KB Partially correct
2 Correct 101 ms 64996 KB Output is correct
3 Partially correct 88 ms 64996 KB Partially correct
4 Correct 100 ms 65200 KB Output is correct
5 Correct 83 ms 65200 KB Output is correct
6 Correct 84 ms 65200 KB Output is correct
7 Partially correct 92 ms 65200 KB Partially correct
8 Partially correct 89 ms 65200 KB Partially correct
9 Correct 117 ms 65200 KB Output is correct
10 Partially correct 381 ms 69372 KB Partially correct
11 Correct 128 ms 69372 KB Output is correct
12 Partially correct 174 ms 69372 KB Partially correct
13 Correct 136 ms 69372 KB Output is correct
14 Correct 140 ms 69372 KB Output is correct
15 Partially correct 172 ms 69372 KB Partially correct
16 Correct 166 ms 69372 KB Output is correct
17 Partially correct 161 ms 69372 KB Partially correct
18 Correct 161 ms 69372 KB Output is correct
19 Partially correct 238 ms 69372 KB Partially correct
20 Correct 414 ms 70652 KB Output is correct
21 Correct 191 ms 70652 KB Output is correct
22 Partially correct 183 ms 70652 KB Partially correct
23 Partially correct 193 ms 70652 KB Partially correct
24 Partially correct 196 ms 70652 KB Partially correct
25 Correct 181 ms 70652 KB Output is correct
26 Partially correct 177 ms 70652 KB Partially correct
27 Partially correct 212 ms 70652 KB Partially correct
28 Partially correct 252 ms 70652 KB Partially correct
29 Partially correct 312 ms 70652 KB Partially correct
30 Correct 486 ms 71152 KB Output is correct
31 Correct 251 ms 71152 KB Output is correct
32 Partially correct 222 ms 71152 KB Partially correct
33 Partially correct 235 ms 71152 KB Partially correct
34 Correct 254 ms 71152 KB Output is correct
35 Correct 246 ms 71152 KB Output is correct
36 Correct 244 ms 71152 KB Output is correct
37 Correct 259 ms 71152 KB Output is correct
38 Partially correct 279 ms 71152 KB Partially correct
39 Partially correct 268 ms 71152 KB Partially correct
40 Correct 443 ms 71152 KB Output is correct
41 Partially correct 605 ms 73212 KB Partially correct