Submission #110778

# Submission time Handle Problem Language Result Execution time Memory
110778 2019-05-12T08:13:07 Z ckodser 007 (CEOI14_007) C++14
0 / 100
386 ms 23860 KB
#include<bits/stdc++.h>

#define ll long long
#define pb push_back
#define mp make_pair
#define ld long double
#define F first
#define S second
#define pii pair<ll,ll> 

using namespace :: std;

const ll mod=1e9+7;
const ll maxn=2e5+500;
const ll inf=1e9+900;

vector<ll> ger[maxn];
ll fs[maxn];
ll fd[maxn];
bool vis[maxn];

void bfs(ll a,ll* f){
    queue<ll> qu;
    memset(vis,0,sizeof vis);
    qu.push(a);
    vis[a]=1;
    while(qu.size()){
	ll v=qu.front();
	qu.pop();
	for(auto u:ger[v]){
	    if(!vis[u]){
		vis[u]=1;
		f[u]=f[v]+1;
		qu.push(u);
	    }
	}
    }
}
int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    ll n,m;
    cin>>n>>m;
    ll s,d,a,b;
    cin>>s>>d>>a>>b;
    for(ll i=0;i<m;i++){
	ll a,b;
	cin>>a>>b;
	ger[a].pb(b);
	ger[b].pb(a);
    }
    bfs(s,fs);
    bfs(d,fd);
    if(fd[a]!=fd[b]){
	ll r1=fd[a];
	ll r2=fd[b];
	ll w1=fs[a];
	ll w2=fs[b];
	if(r1>r2){
	    swap(r1,r2);
	    swap(w1,w2);
	}	
	ll ans=min(r1-w1,r2-w2);
	if(ans<0){
	    ans=-1;
	}
	cout<<ans<<endl;
    }else{
	cout<<"WTF?";
	exit(1);
    }	
}
# Verdict Execution time Memory Grader output
1 Runtime error 7 ms 5248 KB Execution failed because the return code was nonzero
2 Correct 6 ms 5248 KB Output is correct
3 Runtime error 7 ms 5248 KB Execution failed because the return code was nonzero
4 Runtime error 8 ms 5248 KB Execution failed because the return code was nonzero
5 Runtime error 7 ms 5248 KB Execution failed because the return code was nonzero
6 Runtime error 8 ms 5220 KB Execution failed because the return code was nonzero
7 Runtime error 7 ms 5248 KB Execution failed because the return code was nonzero
8 Runtime error 6 ms 5248 KB Execution failed because the return code was nonzero
9 Runtime error 8 ms 5248 KB Execution failed because the return code was nonzero
10 Runtime error 9 ms 5248 KB Execution failed because the return code was nonzero
11 Correct 9 ms 5248 KB Output is correct
12 Runtime error 4 ms 5208 KB Execution failed because the return code was nonzero
13 Runtime error 7 ms 5248 KB Execution failed because the return code was nonzero
14 Runtime error 9 ms 5248 KB Execution failed because the return code was nonzero
15 Runtime error 7 ms 5248 KB Execution failed because the return code was nonzero
16 Runtime error 7 ms 5376 KB Execution failed because the return code was nonzero
17 Runtime error 7 ms 5248 KB Execution failed because the return code was nonzero
18 Runtime error 8 ms 5248 KB Execution failed because the return code was nonzero
19 Runtime error 8 ms 5248 KB Execution failed because the return code was nonzero
20 Runtime error 8 ms 5248 KB Execution failed because the return code was nonzero
21 Correct 7 ms 5292 KB Output is correct
22 Runtime error 8 ms 5248 KB Execution failed because the return code was nonzero
23 Runtime error 11 ms 5248 KB Execution failed because the return code was nonzero
24 Runtime error 8 ms 5376 KB Execution failed because the return code was nonzero
# Verdict Execution time Memory Grader output
1 Runtime error 40 ms 7268 KB Execution failed because the return code was nonzero
2 Runtime error 47 ms 8036 KB Execution failed because the return code was nonzero
3 Runtime error 36 ms 7416 KB Execution failed because the return code was nonzero
4 Runtime error 48 ms 8184 KB Execution failed because the return code was nonzero
5 Correct 42 ms 7164 KB Output is correct
6 Correct 36 ms 7400 KB Output is correct
7 Runtime error 34 ms 7644 KB Execution failed because the return code was nonzero
8 Runtime error 35 ms 7544 KB Execution failed because the return code was nonzero
9 Runtime error 62 ms 8824 KB Execution failed because the return code was nonzero
10 Runtime error 169 ms 17464 KB Execution failed because the return code was nonzero
11 Runtime error 70 ms 9592 KB Execution failed because the return code was nonzero
12 Runtime error 94 ms 10948 KB Execution failed because the return code was nonzero
13 Runtime error 67 ms 9976 KB Execution failed because the return code was nonzero
14 Runtime error 47 ms 9212 KB Execution failed because the return code was nonzero
15 Runtime error 93 ms 10872 KB Execution failed because the return code was nonzero
16 Correct 88 ms 11000 KB Output is correct
17 Runtime error 77 ms 10468 KB Execution failed because the return code was nonzero
18 Runtime error 111 ms 10508 KB Execution failed because the return code was nonzero
19 Runtime error 156 ms 13432 KB Execution failed because the return code was nonzero
20 Runtime error 308 ms 19420 KB Execution failed because the return code was nonzero
21 Runtime error 145 ms 12792 KB Execution failed because the return code was nonzero
22 Runtime error 101 ms 11900 KB Execution failed because the return code was nonzero
23 Correct 144 ms 12648 KB Output is correct
24 Runtime error 124 ms 12696 KB Execution failed because the return code was nonzero
25 Runtime error 131 ms 12280 KB Execution failed because the return code was nonzero
26 Correct 117 ms 11952 KB Output is correct
27 Runtime error 136 ms 13020 KB Execution failed because the return code was nonzero
28 Runtime error 181 ms 13048 KB Execution failed because the return code was nonzero
29 Runtime error 195 ms 15480 KB Execution failed because the return code was nonzero
30 Runtime error 372 ms 20224 KB Execution failed because the return code was nonzero
31 Runtime error 149 ms 13948 KB Execution failed because the return code was nonzero
32 Runtime error 146 ms 12796 KB Execution failed because the return code was nonzero
33 Correct 149 ms 13108 KB Output is correct
34 Runtime error 164 ms 13544 KB Execution failed because the return code was nonzero
35 Runtime error 144 ms 13024 KB Execution failed because the return code was nonzero
36 Runtime error 158 ms 13296 KB Execution failed because the return code was nonzero
37 Correct 194 ms 14428 KB Output is correct
38 Runtime error 181 ms 14328 KB Execution failed because the return code was nonzero
39 Runtime error 192 ms 14328 KB Execution failed because the return code was nonzero
40 Runtime error 243 ms 18848 KB Execution failed because the return code was nonzero
41 Runtime error 386 ms 23860 KB Execution failed because the return code was nonzero