# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
82364 |
2018-10-30T09:57:46 Z |
EntityIT |
007 (CEOI14_007) |
C++14 |
|
370 ms |
16636 KB |
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
typedef pair<int, int> ii;
const int N = 2e5 + 5, inf = 1e9 + 123;
int n, m, src[2], a[2], d[2][N], l = -1, r = 6e5 + 5;
vector<int> gr[N];
void dijkstra (bool _) {
for (int i = 1; i <= n; ++i) d[_][i] = inf;
d[_][ src[_] ] = 0;
priority_queue<ii, vector<ii>, greater<ii> > pq; pq.push(ii(d[_][ src[_] ], src[_]) );
while (!pq.empty() ) {
ii tmp = pq.top(); pq.pop();
int u = tmp.se;
if (tmp.fi > d[_][u]) continue ;
for (int v : gr[u]) {
if (d[_][v] > d[_][u] + 1) {
d[_][v] = d[_][u] + 1;
pq.push(ii(d[_][v], v) );
}
}
}
}
bool check (int Time) {
d[1][ a[0] ] -= Time;
d[1][ a[1] ] -= Time;
if (d[0][ a[0] ] > d[1][ a[0] ] || d[0][ a[1] ] > d[1][ a[1] ]) {
d[1][ a[0] ] += Time;
d[1][ a[1] ] += Time;
return false;
}
d[1][ a[0] ] += Time;
d[1][ a[1] ] += Time;
return true;
}
int main () {
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
// freopen("SPY.INP", "r", stdin);
// freopen("SPY.OUT", "w", stdout);
cin >> n >> m;
cin >> src[0] >> src[1] >> a[0] >> a[1];
while (m --) {
int u, v; cin >> u >> v;
gr[u].pb(v); gr[v].pb(u);
}
dijkstra(0);
dijkstra(1);
while (l < r) {
int mid = (l + r + 1) / 2;
if (check(mid) ) l = mid;
else r = mid - 1;
}
cout << l;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
4984 KB |
Output is correct |
2 |
Correct |
6 ms |
5236 KB |
Output is correct |
3 |
Correct |
6 ms |
5236 KB |
Output is correct |
4 |
Incorrect |
6 ms |
5236 KB |
Output isn't correct |
5 |
Incorrect |
6 ms |
5236 KB |
Output isn't correct |
6 |
Correct |
6 ms |
5236 KB |
Output is correct |
7 |
Correct |
6 ms |
5236 KB |
Output is correct |
8 |
Incorrect |
6 ms |
5252 KB |
Output isn't correct |
9 |
Correct |
6 ms |
5252 KB |
Output is correct |
10 |
Correct |
6 ms |
5328 KB |
Output is correct |
11 |
Correct |
6 ms |
5328 KB |
Output is correct |
12 |
Incorrect |
6 ms |
5344 KB |
Output isn't correct |
13 |
Correct |
6 ms |
5344 KB |
Output is correct |
14 |
Incorrect |
6 ms |
5344 KB |
Output isn't correct |
15 |
Correct |
6 ms |
5344 KB |
Output is correct |
16 |
Incorrect |
6 ms |
5484 KB |
Output isn't correct |
17 |
Incorrect |
6 ms |
5484 KB |
Output isn't correct |
18 |
Incorrect |
6 ms |
5484 KB |
Output isn't correct |
19 |
Correct |
6 ms |
5484 KB |
Output is correct |
20 |
Correct |
6 ms |
5484 KB |
Output is correct |
21 |
Correct |
7 ms |
5484 KB |
Output is correct |
22 |
Correct |
7 ms |
5484 KB |
Output is correct |
23 |
Correct |
6 ms |
5484 KB |
Output is correct |
24 |
Incorrect |
7 ms |
5496 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
34 ms |
6908 KB |
Output is correct |
2 |
Incorrect |
44 ms |
7548 KB |
Output isn't correct |
3 |
Correct |
42 ms |
7548 KB |
Output is correct |
4 |
Incorrect |
45 ms |
7676 KB |
Output isn't correct |
5 |
Correct |
37 ms |
7676 KB |
Output is correct |
6 |
Correct |
32 ms |
7676 KB |
Output is correct |
7 |
Correct |
44 ms |
7676 KB |
Output is correct |
8 |
Correct |
45 ms |
7676 KB |
Output is correct |
9 |
Incorrect |
54 ms |
7676 KB |
Output isn't correct |
10 |
Correct |
177 ms |
12028 KB |
Output is correct |
11 |
Incorrect |
95 ms |
12028 KB |
Output isn't correct |
12 |
Correct |
123 ms |
12028 KB |
Output is correct |
13 |
Incorrect |
100 ms |
12028 KB |
Output isn't correct |
14 |
Correct |
81 ms |
12028 KB |
Output is correct |
15 |
Correct |
134 ms |
12028 KB |
Output is correct |
16 |
Correct |
108 ms |
12028 KB |
Output is correct |
17 |
Correct |
107 ms |
12028 KB |
Output is correct |
18 |
Incorrect |
125 ms |
12028 KB |
Output isn't correct |
19 |
Correct |
142 ms |
12028 KB |
Output is correct |
20 |
Incorrect |
241 ms |
13696 KB |
Output isn't correct |
21 |
Incorrect |
151 ms |
13696 KB |
Output isn't correct |
22 |
Correct |
149 ms |
13696 KB |
Output is correct |
23 |
Correct |
156 ms |
13696 KB |
Output is correct |
24 |
Correct |
142 ms |
13696 KB |
Output is correct |
25 |
Incorrect |
153 ms |
13696 KB |
Output isn't correct |
26 |
Correct |
165 ms |
13696 KB |
Output is correct |
27 |
Correct |
193 ms |
13696 KB |
Output is correct |
28 |
Correct |
201 ms |
13696 KB |
Output is correct |
29 |
Correct |
204 ms |
13696 KB |
Output is correct |
30 |
Incorrect |
266 ms |
14308 KB |
Output isn't correct |
31 |
Incorrect |
176 ms |
14308 KB |
Output isn't correct |
32 |
Correct |
181 ms |
14308 KB |
Output is correct |
33 |
Correct |
170 ms |
14308 KB |
Output is correct |
34 |
Incorrect |
218 ms |
14308 KB |
Output isn't correct |
35 |
Incorrect |
154 ms |
14308 KB |
Output isn't correct |
36 |
Incorrect |
170 ms |
14308 KB |
Output isn't correct |
37 |
Correct |
231 ms |
14308 KB |
Output is correct |
38 |
Correct |
215 ms |
14308 KB |
Output is correct |
39 |
Correct |
238 ms |
14308 KB |
Output is correct |
40 |
Incorrect |
285 ms |
14512 KB |
Output isn't correct |
41 |
Correct |
370 ms |
16636 KB |
Output is correct |