# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
29917 | 2017-07-21T10:39:07 Z | PrOAhMeT | 007 (CEOI14_007) | C++14 | 363 ms | 18168 KB |
#include <bits/stdc++.h> #define mp make_pair #define pb push_back #define pii pair<int,int> #define LL long long #define st first #define nd second #define endl '\n' using namespace std; const int MAXN=200005; int n,m,dis[2][MAXN],s,d,a,b,t,tt; vector<int> v[MAXN]; void bfs(int start,int wait,int u) { memset(dis[u],-1,sizeof dis[u]); queue<int> q; dis[u][start]=0; int x,y; q.push(start); while(!q.empty()) { x=q.front(); q.pop(); for(int i=0;i<v[x].size();++i) { y=v[x][i]; if(dis[u][y]==-1) { dis[u][y]=dis[u][x]+1; q.push(y); } } } } int main() { scanf("%d %d",&n,&m); scanf("%d %d %d %d",&s,&d,&a,&b); for(int i=0;i<m;++i) { scanf("%d %d",&t,&tt); v[t].pb(tt); v[tt].pb(t); } int l=0,r=n,ans=-1,md; bfs(d,0,1); bfs(s,0,0); if(dis[0][a]>dis[1][a]||dis[0][b]>dis[1][b]) cout<<-1<<endl; else { cout<<min(dis[1][a]-dis[0][a],dis[1][b]-dis[0][b])<<endl; } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 8268 KB | Output is correct |
2 | Correct | 0 ms | 8268 KB | Output is correct |
3 | Correct | 3 ms | 8268 KB | Output is correct |
4 | Incorrect | 0 ms | 8268 KB | Output isn't correct |
5 | Incorrect | 0 ms | 8268 KB | Output isn't correct |
6 | Correct | 0 ms | 8268 KB | Output is correct |
7 | Correct | 0 ms | 8268 KB | Output is correct |
8 | Incorrect | 3 ms | 8268 KB | Output isn't correct |
9 | Correct | 0 ms | 8268 KB | Output is correct |
10 | Correct | 0 ms | 8268 KB | Output is correct |
11 | Correct | 3 ms | 8268 KB | Output is correct |
12 | Incorrect | 0 ms | 8268 KB | Output isn't correct |
13 | Correct | 0 ms | 8268 KB | Output is correct |
14 | Incorrect | 0 ms | 8268 KB | Output isn't correct |
15 | Correct | 3 ms | 8268 KB | Output is correct |
16 | Incorrect | 0 ms | 8268 KB | Output isn't correct |
17 | Incorrect | 0 ms | 8268 KB | Output isn't correct |
18 | Incorrect | 0 ms | 8268 KB | Output isn't correct |
19 | Correct | 0 ms | 8268 KB | Output is correct |
20 | Correct | 3 ms | 8268 KB | Output is correct |
21 | Correct | 0 ms | 8268 KB | Output is correct |
22 | Correct | 0 ms | 8268 KB | Output is correct |
23 | Correct | 3 ms | 8268 KB | Output is correct |
24 | Incorrect | 0 ms | 8268 KB | Output isn't correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 33 ms | 9588 KB | Output is correct |
2 | Incorrect | 46 ms | 10116 KB | Output isn't correct |
3 | Correct | 29 ms | 9588 KB | Output is correct |
4 | Incorrect | 29 ms | 10248 KB | Output isn't correct |
5 | Correct | 33 ms | 9456 KB | Output is correct |
6 | Correct | 26 ms | 9720 KB | Output is correct |
7 | Correct | 23 ms | 9852 KB | Output is correct |
8 | Correct | 43 ms | 9852 KB | Output is correct |
9 | Incorrect | 59 ms | 10248 KB | Output isn't correct |
10 | Correct | 186 ms | 14472 KB | Output is correct |
11 | Incorrect | 79 ms | 11172 KB | Output isn't correct |
12 | Correct | 109 ms | 11832 KB | Output is correct |
13 | Incorrect | 93 ms | 11304 KB | Output isn't correct |
14 | Correct | 63 ms | 10908 KB | Output is correct |
15 | Correct | 96 ms | 11964 KB | Output is correct |
16 | Correct | 103 ms | 12096 KB | Output is correct |
17 | Correct | 83 ms | 11700 KB | Output is correct |
18 | Incorrect | 83 ms | 11700 KB | Output isn't correct |
19 | Correct | 146 ms | 12888 KB | Output is correct |
20 | Incorrect | 266 ms | 15660 KB | Output isn't correct |
21 | Incorrect | 133 ms | 13284 KB | Output isn't correct |
22 | Correct | 133 ms | 12624 KB | Output is correct |
23 | Correct | 133 ms | 13284 KB | Output is correct |
24 | Correct | 126 ms | 13152 KB | Output is correct |
25 | Incorrect | 119 ms | 12888 KB | Output isn't correct |
26 | Correct | 139 ms | 12624 KB | Output is correct |
27 | Correct | 146 ms | 13284 KB | Output is correct |
28 | Correct | 186 ms | 13284 KB | Output is correct |
29 | Correct | 216 ms | 14076 KB | Output is correct |
30 | Incorrect | 253 ms | 16188 KB | Output isn't correct |
31 | Incorrect | 173 ms | 14076 KB | Output isn't correct |
32 | Correct | 133 ms | 13284 KB | Output is correct |
33 | Correct | 143 ms | 13416 KB | Output is correct |
34 | Incorrect | 186 ms | 13680 KB | Output isn't correct |
35 | Incorrect | 153 ms | 13416 KB | Output isn't correct |
36 | Incorrect | 139 ms | 13680 KB | Output isn't correct |
37 | Correct | 146 ms | 14340 KB | Output is correct |
38 | Correct | 159 ms | 14208 KB | Output is correct |
39 | Correct | 183 ms | 14208 KB | Output is correct |
40 | Incorrect | 293 ms | 15924 KB | Output isn't correct |
41 | Correct | 363 ms | 18168 KB | Output is correct |