# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
123547 |
2019-07-01T15:17:07 Z |
Noam527 |
007 (CEOI14_007) |
C++17 |
|
302 ms |
22268 KB |
#include <bits/stdc++.h>
#define finish(x) return cout << x << endl, 0
typedef long long ll;
typedef long double ldb;
const int md = 1e9 + 7;
const ll inf = 1e18;
const int OO = 1;
const int OOO = 1;
using namespace std;
int n, m;
int st7, stn, a, b;
vector<vector<int>> g;
vector<int> d;
void bfs(int st) {
for (auto &i : d) i = -1;
d[st] = 0;
queue<int> q;
q.push(st);
while (q.size()) {
int x = q.front();
q.pop();
for (const auto &i : g[x])
if (d[i] == -1) {
d[i] = 1 + d[x];
q.push(i);
}
}
}
int main() {
ios::sync_with_stdio(0), cin.tie(0);
cin >> n >> m >> st7 >> stn >> a >> b;
--st7, --stn, --a, --b;
g.resize(n);
d.resize(n);
for (int i = 0, u, v; i < m; i++) {
cin >> u >> v;
--u, --v;
g[u].push_back(v);
g[v].push_back(u);
}
bfs(st7);
int D7[2] = { d[a], d[b] };
bfs(stn);
int Dn[2] = { d[a], d[b] };
int ans = min(Dn[0] - D7[0], Dn[1] - D7[1]);
cout << max(ans, -1) << '\n';
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
5 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
8 |
Incorrect |
2 ms |
380 KB |
Output isn't correct |
9 |
Correct |
2 ms |
376 KB |
Output is correct |
10 |
Correct |
2 ms |
376 KB |
Output is correct |
11 |
Correct |
2 ms |
376 KB |
Output is correct |
12 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
13 |
Correct |
2 ms |
376 KB |
Output is correct |
14 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
15 |
Correct |
2 ms |
376 KB |
Output is correct |
16 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
17 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
18 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
19 |
Correct |
2 ms |
376 KB |
Output is correct |
20 |
Correct |
2 ms |
376 KB |
Output is correct |
21 |
Correct |
2 ms |
376 KB |
Output is correct |
22 |
Correct |
3 ms |
376 KB |
Output is correct |
23 |
Correct |
2 ms |
376 KB |
Output is correct |
24 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
25 ms |
3196 KB |
Output is correct |
2 |
Incorrect |
35 ms |
4472 KB |
Output isn't correct |
3 |
Correct |
28 ms |
3448 KB |
Output is correct |
4 |
Incorrect |
35 ms |
4604 KB |
Output isn't correct |
5 |
Correct |
25 ms |
3192 KB |
Output is correct |
6 |
Correct |
26 ms |
3576 KB |
Output is correct |
7 |
Correct |
30 ms |
3832 KB |
Output is correct |
8 |
Correct |
30 ms |
3832 KB |
Output is correct |
9 |
Incorrect |
47 ms |
4704 KB |
Output isn't correct |
10 |
Correct |
171 ms |
13404 KB |
Output is correct |
11 |
Incorrect |
57 ms |
6776 KB |
Output isn't correct |
12 |
Correct |
87 ms |
8440 KB |
Output is correct |
13 |
Incorrect |
65 ms |
7288 KB |
Output isn't correct |
14 |
Correct |
50 ms |
6136 KB |
Output is correct |
15 |
Correct |
71 ms |
8572 KB |
Output is correct |
16 |
Correct |
77 ms |
9008 KB |
Output is correct |
17 |
Correct |
71 ms |
8060 KB |
Output is correct |
18 |
Incorrect |
68 ms |
8056 KB |
Output isn't correct |
19 |
Correct |
108 ms |
10488 KB |
Output is correct |
20 |
Incorrect |
213 ms |
16324 KB |
Output isn't correct |
21 |
Incorrect |
114 ms |
11872 KB |
Output isn't correct |
22 |
Correct |
103 ms |
10232 KB |
Output is correct |
23 |
Correct |
125 ms |
11512 KB |
Output is correct |
24 |
Correct |
120 ms |
11512 KB |
Output is correct |
25 |
Incorrect |
108 ms |
10876 KB |
Output isn't correct |
26 |
Correct |
92 ms |
10360 KB |
Output is correct |
27 |
Correct |
173 ms |
11840 KB |
Output is correct |
28 |
Correct |
133 ms |
11772 KB |
Output is correct |
29 |
Correct |
151 ms |
13256 KB |
Output is correct |
30 |
Incorrect |
237 ms |
17756 KB |
Output isn't correct |
31 |
Incorrect |
151 ms |
13636 KB |
Output isn't correct |
32 |
Correct |
158 ms |
11768 KB |
Output is correct |
33 |
Correct |
219 ms |
12172 KB |
Output is correct |
34 |
Incorrect |
138 ms |
12664 KB |
Output isn't correct |
35 |
Incorrect |
118 ms |
12208 KB |
Output isn't correct |
36 |
Incorrect |
124 ms |
12656 KB |
Output isn't correct |
37 |
Correct |
145 ms |
14200 KB |
Output is correct |
38 |
Correct |
154 ms |
13916 KB |
Output is correct |
39 |
Correct |
149 ms |
14056 KB |
Output is correct |
40 |
Incorrect |
222 ms |
17528 KB |
Output isn't correct |
41 |
Correct |
302 ms |
22268 KB |
Output is correct |