# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
43412 | 2018-03-15T20:48:39 Z | Hassoony | 007 (CEOI14_007) | C++14 | 376 ms | 17308 KB |
#include<bits/stdc++.h> using namespace std; typedef long long ll; const int MX=2e5+9; int n,m,a,b,s,d,dis[MX],dis1[MX],x,y,vis[MX]; vector<int>v[MX]; void bfs(int x,int y){ for(int i=1;i<=n;i++)dis[i]=MX,vis[i]=0; dis[x]=0; queue<int>q; q.push(x); while(!q.empty()){ int node=q.front();q.pop(); if(vis[node])continue; vis[node]=1; for(auto pp:v[node]){ if(pp==y)continue; if(dis[pp]==MX){ dis[pp]=dis[node]+1; q.push(pp); } } } } 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",&x,&y); v[x].push_back(y); v[y].push_back(x); } bfs(s,d); for(int i=1;i<=n;i++)dis1[i]=dis[i]; bfs(d,s); if(dis[a]<dis1[a]||dis[b]<dis1[b]){ puts("-1"); return 0; } bfs(s,0); for(int i=1;i<=n;i++)dis1[i]=dis[i]; bfs(d,0); if(dis[a]<dis[b]){ cout<<dis[a]-dis1[a]<<endl; } else cout<<dis[b]-dis1[b]<<endl; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 5 ms | 4988 KB | Output isn't correct |
2 | Correct | 5 ms | 5088 KB | Output is correct |
3 | Correct | 5 ms | 5088 KB | Output is correct |
4 | Incorrect | 5 ms | 5144 KB | Output isn't correct |
5 | Incorrect | 5 ms | 5144 KB | Output isn't correct |
6 | Correct | 5 ms | 5216 KB | Output is correct |
7 | Correct | 5 ms | 5220 KB | Output is correct |
8 | Incorrect | 5 ms | 5220 KB | Output isn't correct |
9 | Correct | 5 ms | 5220 KB | Output is correct |
10 | Incorrect | 5 ms | 5220 KB | Output isn't correct |
11 | Correct | 5 ms | 5220 KB | Output is correct |
12 | Incorrect | 5 ms | 5220 KB | Output isn't correct |
13 | Correct | 5 ms | 5284 KB | Output is correct |
14 | Incorrect | 7 ms | 5284 KB | Output isn't correct |
15 | Correct | 5 ms | 5284 KB | Output is correct |
16 | Incorrect | 5 ms | 5284 KB | Output isn't correct |
17 | Incorrect | 5 ms | 5356 KB | Output isn't correct |
18 | Incorrect | 5 ms | 5356 KB | Output isn't correct |
19 | Correct | 5 ms | 5356 KB | Output is correct |
20 | Correct | 6 ms | 5356 KB | Output is correct |
21 | Correct | 5 ms | 5356 KB | Output is correct |
22 | Correct | 5 ms | 5356 KB | Output is correct |
23 | Correct | 5 ms | 5356 KB | Output is correct |
24 | Incorrect | 6 ms | 5356 KB | Output isn't correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 29 ms | 6996 KB | Output is correct |
2 | Incorrect | 39 ms | 7788 KB | Output isn't correct |
3 | Correct | 31 ms | 7788 KB | Output is correct |
4 | Incorrect | 39 ms | 7892 KB | Output isn't correct |
5 | Correct | 31 ms | 7892 KB | Output is correct |
6 | Correct | 29 ms | 7892 KB | Output is correct |
7 | Correct | 35 ms | 7892 KB | Output is correct |
8 | Correct | 34 ms | 7892 KB | Output is correct |
9 | Incorrect | 53 ms | 7892 KB | Output isn't correct |
10 | Correct | 189 ms | 12196 KB | Output is correct |
11 | Incorrect | 68 ms | 12196 KB | Output isn't correct |
12 | Correct | 87 ms | 12196 KB | Output is correct |
13 | Incorrect | 78 ms | 12196 KB | Output isn't correct |
14 | Correct | 56 ms | 12196 KB | Output is correct |
15 | Correct | 85 ms | 12196 KB | Output is correct |
16 | Correct | 86 ms | 12196 KB | Output is correct |
17 | Correct | 78 ms | 12196 KB | Output is correct |
18 | Incorrect | 77 ms | 12196 KB | Output isn't correct |
19 | Correct | 134 ms | 12196 KB | Output is correct |
20 | Incorrect | 261 ms | 13932 KB | Output isn't correct |
21 | Incorrect | 124 ms | 13932 KB | Output isn't correct |
22 | Correct | 128 ms | 13932 KB | Output is correct |
23 | Correct | 118 ms | 13932 KB | Output is correct |
24 | Correct | 112 ms | 13932 KB | Output is correct |
25 | Incorrect | 114 ms | 13932 KB | Output isn't correct |
26 | Correct | 107 ms | 13932 KB | Output is correct |
27 | Correct | 124 ms | 13932 KB | Output is correct |
28 | Correct | 171 ms | 13932 KB | Output is correct |
29 | Correct | 209 ms | 13932 KB | Output is correct |
30 | Incorrect | 279 ms | 14740 KB | Output isn't correct |
31 | Incorrect | 147 ms | 14740 KB | Output isn't correct |
32 | Correct | 157 ms | 14740 KB | Output is correct |
33 | Correct | 133 ms | 14740 KB | Output is correct |
34 | Incorrect | 166 ms | 14740 KB | Output isn't correct |
35 | Incorrect | 129 ms | 14740 KB | Output isn't correct |
36 | Incorrect | 135 ms | 14740 KB | Output isn't correct |
37 | Correct | 169 ms | 14740 KB | Output is correct |
38 | Correct | 181 ms | 14740 KB | Output is correct |
39 | Correct | 246 ms | 14740 KB | Output is correct |
40 | Incorrect | 249 ms | 14940 KB | Output isn't correct |
41 | Correct | 376 ms | 17308 KB | Output is correct |