Submission #90660

# Submission time Handle Problem Language Result Execution time Memory
90660 2018-12-23T10:13:54 Z 314rate 007 (CEOI14_007) C++14
0 / 100
6 ms 5408 KB
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;

const int N=200000+5;

int n,m;
int s,d,a,b;
vector<int>g[N];

int di[2][N];

void build(int k,int go)
{
    for(int i=1;i<=n;i++)
    {
        di[k][i]=-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 x=max(a1,a2);
    int y=max(b1,b2);
    int ans=y-x;
    if(ans>=0)
    {
        cout<<ans<<"\n";
    }
    else
    {
        cout<<"-1\n";
    }
    return 0;
    cout<<a1<<" "<<a2<<" ; "<<b1<<" "<<b2<<"\n";
    return 0;
}
/**


**/

Compilation message

007.cpp: In function 'int main()':
007.cpp:42:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
     freopen("input","r",stdin);
     ~~~~~~~^~~~~~~~~~~~~~~~~~~
007.cpp:43:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
     freopen("output","w",stdout);
     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 5112 KB Unexpected end of file - int64 expected
2 Incorrect 5 ms 5260 KB Unexpected end of file - int64 expected
3 Incorrect 5 ms 5332 KB Unexpected end of file - int64 expected
4 Incorrect 5 ms 5332 KB Unexpected end of file - int64 expected
5 Incorrect 6 ms 5332 KB Unexpected end of file - int64 expected
6 Incorrect 5 ms 5332 KB Unexpected end of file - int64 expected
7 Incorrect 5 ms 5332 KB Unexpected end of file - int64 expected
8 Incorrect 5 ms 5332 KB Unexpected end of file - int64 expected
9 Incorrect 5 ms 5332 KB Unexpected end of file - int64 expected
10 Incorrect 6 ms 5332 KB Unexpected end of file - int64 expected
11 Incorrect 5 ms 5332 KB Unexpected end of file - int64 expected
12 Incorrect 6 ms 5332 KB Unexpected end of file - int64 expected
13 Incorrect 5 ms 5332 KB Unexpected end of file - int64 expected
14 Incorrect 6 ms 5340 KB Unexpected end of file - int64 expected
15 Incorrect 5 ms 5340 KB Unexpected end of file - int64 expected
16 Incorrect 6 ms 5340 KB Unexpected end of file - int64 expected
17 Incorrect 6 ms 5340 KB Unexpected end of file - int64 expected
18 Incorrect 5 ms 5340 KB Unexpected end of file - int64 expected
19 Incorrect 5 ms 5340 KB Unexpected end of file - int64 expected
20 Incorrect 5 ms 5340 KB Unexpected end of file - int64 expected
21 Incorrect 5 ms 5340 KB Unexpected end of file - int64 expected
22 Incorrect 5 ms 5340 KB Unexpected end of file - int64 expected
23 Incorrect 5 ms 5340 KB Unexpected end of file - int64 expected
24 Incorrect 6 ms 5340 KB Unexpected end of file - int64 expected
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 5340 KB Unexpected end of file - int64 expected
2 Incorrect 5 ms 5340 KB Unexpected end of file - int64 expected
3 Incorrect 5 ms 5340 KB Unexpected end of file - int64 expected
4 Incorrect 5 ms 5340 KB Unexpected end of file - int64 expected
5 Incorrect 6 ms 5340 KB Unexpected end of file - int64 expected
6 Incorrect 5 ms 5340 KB Unexpected end of file - int64 expected
7 Incorrect 6 ms 5340 KB Unexpected end of file - int64 expected
8 Incorrect 6 ms 5340 KB Unexpected end of file - int64 expected
9 Incorrect 5 ms 5340 KB Unexpected end of file - int64 expected
10 Incorrect 6 ms 5340 KB Unexpected end of file - int64 expected
11 Incorrect 6 ms 5340 KB Unexpected end of file - int64 expected
12 Incorrect 5 ms 5340 KB Unexpected end of file - int64 expected
13 Incorrect 5 ms 5340 KB Unexpected end of file - int64 expected
14 Incorrect 6 ms 5340 KB Unexpected end of file - int64 expected
15 Incorrect 5 ms 5340 KB Unexpected end of file - int64 expected
16 Incorrect 5 ms 5340 KB Unexpected end of file - int64 expected
17 Incorrect 5 ms 5408 KB Unexpected end of file - int64 expected
18 Incorrect 5 ms 5408 KB Unexpected end of file - int64 expected
19 Incorrect 5 ms 5408 KB Unexpected end of file - int64 expected
20 Incorrect 5 ms 5408 KB Unexpected end of file - int64 expected
21 Incorrect 5 ms 5408 KB Unexpected end of file - int64 expected
22 Incorrect 5 ms 5408 KB Unexpected end of file - int64 expected
23 Incorrect 5 ms 5408 KB Unexpected end of file - int64 expected
24 Incorrect 5 ms 5408 KB Unexpected end of file - int64 expected
25 Incorrect 5 ms 5408 KB Unexpected end of file - int64 expected
26 Incorrect 6 ms 5408 KB Unexpected end of file - int64 expected
27 Incorrect 6 ms 5408 KB Unexpected end of file - int64 expected
28 Incorrect 5 ms 5408 KB Unexpected end of file - int64 expected
29 Incorrect 5 ms 5408 KB Unexpected end of file - int64 expected
30 Incorrect 5 ms 5408 KB Unexpected end of file - int64 expected
31 Incorrect 6 ms 5408 KB Unexpected end of file - int64 expected
32 Incorrect 5 ms 5408 KB Unexpected end of file - int64 expected
33 Incorrect 6 ms 5408 KB Unexpected end of file - int64 expected
34 Incorrect 5 ms 5408 KB Unexpected end of file - int64 expected
35 Incorrect 5 ms 5408 KB Unexpected end of file - int64 expected
36 Incorrect 5 ms 5408 KB Unexpected end of file - int64 expected
37 Incorrect 6 ms 5408 KB Unexpected end of file - int64 expected
38 Incorrect 6 ms 5408 KB Unexpected end of file - int64 expected
39 Incorrect 6 ms 5408 KB Unexpected end of file - int64 expected
40 Incorrect 5 ms 5408 KB Unexpected end of file - int64 expected
41 Incorrect 5 ms 5408 KB Unexpected end of file - int64 expected