# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
43401 |
2018-03-15T20:10:43 Z |
XmtosX |
007 (CEOI14_007) |
C++14 |
|
619 ms |
18672 KB |
#include <bits/stdc++.h>
using namespace std;
int n,m,st1,st2,a,b;
vector <int> v[300005];
int bs (int x,int y)
{
queue<int> q;
int lvl[300005]={0};
lvl[x]=1;
q.push(x);
while (!q.empty())
{
int node=q.front();
q.pop();
if (node==y)
return lvl[y];
for (int i=0;i<v[node].size();i++)
{
if (!lvl[v[node][i]])
{
lvl[v[node][i]]=lvl[node]+1;
q.push(v[node][i]);
}
}
}
}
int main()
{
cin >>n>>m>>st1>>st2>>a>>b;
for (int i=0;i<m;i++)
{
int x,y;
cin >>x>>y;
v[x].push_back(y);
v[y].push_back(x);
}
int ans1= (bs(st2,a));
int ans2=(bs(st2,b));
int x;
if (ans2==ans1)
x=max(bs(st1,a),bs(st1,b));
else if (ans1<ans2)
x=bs(st1,a);
else
x=bs(st1,b);
ans1=min(ans1,ans2);
if (x>ans1+1)
cout <<-1;
else
cout<<ans1-x;
return 0;
}
Compilation message
007.cpp: In function 'int bs(int, int)':
007.cpp:17:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (int i=0;i<v[node].size();i++)
^
007.cpp:26:1: warning: control reaches end of non-void function [-Wreturn-type]
}
^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
8440 KB |
Output is correct |
2 |
Correct |
7 ms |
8544 KB |
Output is correct |
3 |
Correct |
7 ms |
8616 KB |
Output is correct |
4 |
Incorrect |
8 ms |
8688 KB |
Output isn't correct |
5 |
Incorrect |
8 ms |
8720 KB |
Output isn't correct |
6 |
Correct |
9 ms |
8796 KB |
Output is correct |
7 |
Correct |
7 ms |
8796 KB |
Output is correct |
8 |
Incorrect |
7 ms |
8796 KB |
Output isn't correct |
9 |
Correct |
8 ms |
8796 KB |
Output is correct |
10 |
Correct |
7 ms |
8876 KB |
Output is correct |
11 |
Correct |
8 ms |
8876 KB |
Output is correct |
12 |
Incorrect |
8 ms |
8876 KB |
Output isn't correct |
13 |
Correct |
8 ms |
8876 KB |
Output is correct |
14 |
Incorrect |
7 ms |
8876 KB |
Output isn't correct |
15 |
Correct |
10 ms |
8876 KB |
Output is correct |
16 |
Incorrect |
8 ms |
8876 KB |
Output isn't correct |
17 |
Incorrect |
8 ms |
8876 KB |
Output isn't correct |
18 |
Incorrect |
8 ms |
8876 KB |
Output isn't correct |
19 |
Correct |
8 ms |
8876 KB |
Output is correct |
20 |
Correct |
10 ms |
8908 KB |
Output is correct |
21 |
Correct |
8 ms |
8908 KB |
Output is correct |
22 |
Correct |
8 ms |
8908 KB |
Output is correct |
23 |
Correct |
10 ms |
8908 KB |
Output is correct |
24 |
Incorrect |
8 ms |
8908 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
48 ms |
10004 KB |
Output is correct |
2 |
Incorrect |
75 ms |
10648 KB |
Output isn't correct |
3 |
Correct |
66 ms |
10648 KB |
Output is correct |
4 |
Incorrect |
68 ms |
10732 KB |
Output isn't correct |
5 |
Correct |
48 ms |
10732 KB |
Output is correct |
6 |
Correct |
47 ms |
10732 KB |
Output is correct |
7 |
Correct |
58 ms |
10732 KB |
Output is correct |
8 |
Correct |
54 ms |
10732 KB |
Output is correct |
9 |
Incorrect |
84 ms |
10860 KB |
Output isn't correct |
10 |
Correct |
358 ms |
15212 KB |
Output is correct |
11 |
Incorrect |
98 ms |
15212 KB |
Output isn't correct |
12 |
Correct |
141 ms |
15212 KB |
Output is correct |
13 |
Incorrect |
112 ms |
15212 KB |
Output isn't correct |
14 |
Correct |
99 ms |
15212 KB |
Output is correct |
15 |
Correct |
142 ms |
15212 KB |
Output is correct |
16 |
Correct |
137 ms |
15212 KB |
Output is correct |
17 |
Correct |
148 ms |
15212 KB |
Output is correct |
18 |
Incorrect |
116 ms |
15212 KB |
Output isn't correct |
19 |
Correct |
217 ms |
15212 KB |
Output is correct |
20 |
Incorrect |
419 ms |
16104 KB |
Output isn't correct |
21 |
Incorrect |
178 ms |
16104 KB |
Output isn't correct |
22 |
Correct |
167 ms |
16104 KB |
Output is correct |
23 |
Correct |
185 ms |
16104 KB |
Output is correct |
24 |
Correct |
193 ms |
16104 KB |
Output is correct |
25 |
Incorrect |
191 ms |
16104 KB |
Output isn't correct |
26 |
Correct |
200 ms |
16104 KB |
Output is correct |
27 |
Correct |
169 ms |
16104 KB |
Output is correct |
28 |
Correct |
189 ms |
16104 KB |
Output is correct |
29 |
Correct |
268 ms |
16104 KB |
Output is correct |
30 |
Incorrect |
440 ms |
16748 KB |
Output isn't correct |
31 |
Incorrect |
216 ms |
16748 KB |
Output isn't correct |
32 |
Correct |
213 ms |
16748 KB |
Output is correct |
33 |
Correct |
205 ms |
16748 KB |
Output is correct |
34 |
Incorrect |
254 ms |
16748 KB |
Output isn't correct |
35 |
Incorrect |
181 ms |
16748 KB |
Output isn't correct |
36 |
Incorrect |
196 ms |
16748 KB |
Output isn't correct |
37 |
Correct |
264 ms |
16748 KB |
Output is correct |
38 |
Correct |
223 ms |
16748 KB |
Output is correct |
39 |
Correct |
251 ms |
16748 KB |
Output is correct |
40 |
Incorrect |
370 ms |
16748 KB |
Output isn't correct |
41 |
Correct |
619 ms |
18672 KB |
Output is correct |