# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
43413 |
2018-03-15T20:59:23 Z |
XmtosX |
007 (CEOI14_007) |
C++14 |
|
592 ms |
18928 KB |
#include <bits/stdc++.h>
using namespace std;
int n,m,st1,st2,a,b;
vector <int> v[300005];
int lvl[300005][2];
void bs (int x,int y)
{
queue<int> q;
lvl[x][y]=1;
q.push(x);
while (!q.empty())
{
int node=q.front();
q.pop();
for (int i=0;i<v[node].size();i++)
{
if (!lvl[v[node][i]][y])
{
lvl[v[node][i]][y]=lvl[node][y]+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);
}
bs(st1,1);
bs(st2,0);
vector <int> v1;
for (int i=0;i<v[a].size();i++)
{
if (v[a][i]!=b&&lvl[v[a][i]][0]<lvl[a][0])
v1.push_back(v[a][i]);
}
for (int i=0;i<v[b].size();i++)
{
if (v[b][i]!=a&&lvl[v[b][i]][0]<lvl[b][0])
v1.push_back(v[b][i]);
}
int ans=1e6;
for (int i=0;i<v1.size();i++)
{
ans=min(ans,lvl[v1[i]][0]-lvl[v1[i]][1]);
}
ans=max(ans,min(lvl[a][0]-lvl[a][1],lvl[b][0]-lvl[b][1]));
cout <<max(-1,ans);
return 0;
}
Compilation message
007.cpp: In function 'void bs(int, int)':
007.cpp:15:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (int i=0;i<v[node].size();i++)
^
007.cpp: In function 'int main()':
007.cpp:38:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (int i=0;i<v[a].size();i++)
^
007.cpp:43:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (int i=0;i<v[b].size();i++)
^
007.cpp:49:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (int i=0;i<v1.size();i++)
^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
7288 KB |
Output is correct |
2 |
Correct |
7 ms |
7392 KB |
Output is correct |
3 |
Correct |
7 ms |
7592 KB |
Output is correct |
4 |
Incorrect |
7 ms |
7644 KB |
Output isn't correct |
5 |
Incorrect |
7 ms |
7644 KB |
Output isn't correct |
6 |
Correct |
7 ms |
7644 KB |
Output is correct |
7 |
Correct |
8 ms |
7644 KB |
Output is correct |
8 |
Incorrect |
7 ms |
7644 KB |
Output isn't correct |
9 |
Correct |
7 ms |
7644 KB |
Output is correct |
10 |
Correct |
7 ms |
7644 KB |
Output is correct |
11 |
Correct |
7 ms |
7644 KB |
Output is correct |
12 |
Incorrect |
8 ms |
7644 KB |
Output isn't correct |
13 |
Correct |
7 ms |
7644 KB |
Output is correct |
14 |
Incorrect |
7 ms |
7644 KB |
Output isn't correct |
15 |
Correct |
7 ms |
7644 KB |
Output is correct |
16 |
Incorrect |
7 ms |
7644 KB |
Output isn't correct |
17 |
Incorrect |
7 ms |
7644 KB |
Output isn't correct |
18 |
Incorrect |
7 ms |
7644 KB |
Output isn't correct |
19 |
Correct |
8 ms |
7644 KB |
Output is correct |
20 |
Correct |
8 ms |
7644 KB |
Output is correct |
21 |
Correct |
7 ms |
7644 KB |
Output is correct |
22 |
Correct |
10 ms |
7660 KB |
Output is correct |
23 |
Correct |
7 ms |
7660 KB |
Output is correct |
24 |
Incorrect |
8 ms |
7660 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
50 ms |
9252 KB |
Output is correct |
2 |
Incorrect |
84 ms |
10088 KB |
Output isn't correct |
3 |
Correct |
54 ms |
10088 KB |
Output is correct |
4 |
Incorrect |
66 ms |
10088 KB |
Output isn't correct |
5 |
Correct |
48 ms |
10088 KB |
Output is correct |
6 |
Correct |
48 ms |
10088 KB |
Output is correct |
7 |
Correct |
56 ms |
10088 KB |
Output is correct |
8 |
Correct |
54 ms |
10088 KB |
Output is correct |
9 |
Incorrect |
85 ms |
10088 KB |
Output isn't correct |
10 |
Correct |
407 ms |
14480 KB |
Output is correct |
11 |
Incorrect |
96 ms |
14480 KB |
Output isn't correct |
12 |
Correct |
143 ms |
14480 KB |
Output is correct |
13 |
Incorrect |
115 ms |
14480 KB |
Output isn't correct |
14 |
Correct |
89 ms |
14480 KB |
Output is correct |
15 |
Correct |
129 ms |
14480 KB |
Output is correct |
16 |
Correct |
177 ms |
14480 KB |
Output is correct |
17 |
Correct |
130 ms |
14480 KB |
Output is correct |
18 |
Incorrect |
121 ms |
14480 KB |
Output isn't correct |
19 |
Correct |
214 ms |
14480 KB |
Output is correct |
20 |
Incorrect |
429 ms |
16100 KB |
Output isn't correct |
21 |
Incorrect |
170 ms |
16100 KB |
Output isn't correct |
22 |
Correct |
153 ms |
16100 KB |
Output is correct |
23 |
Correct |
174 ms |
16100 KB |
Output is correct |
24 |
Correct |
177 ms |
16100 KB |
Output is correct |
25 |
Incorrect |
164 ms |
16100 KB |
Output isn't correct |
26 |
Correct |
169 ms |
16100 KB |
Output is correct |
27 |
Correct |
170 ms |
16100 KB |
Output is correct |
28 |
Correct |
184 ms |
16100 KB |
Output is correct |
29 |
Correct |
292 ms |
16100 KB |
Output is correct |
30 |
Incorrect |
464 ms |
16660 KB |
Output isn't correct |
31 |
Incorrect |
205 ms |
16660 KB |
Output isn't correct |
32 |
Correct |
193 ms |
16660 KB |
Output is correct |
33 |
Correct |
187 ms |
16660 KB |
Output is correct |
34 |
Incorrect |
212 ms |
16660 KB |
Output isn't correct |
35 |
Incorrect |
193 ms |
16660 KB |
Output isn't correct |
36 |
Incorrect |
190 ms |
16660 KB |
Output isn't correct |
37 |
Correct |
221 ms |
16660 KB |
Output is correct |
38 |
Correct |
230 ms |
16660 KB |
Output is correct |
39 |
Correct |
240 ms |
16660 KB |
Output is correct |
40 |
Incorrect |
393 ms |
16848 KB |
Output isn't correct |
41 |
Correct |
592 ms |
18928 KB |
Output is correct |