# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
142839 |
2019-08-11T12:09:21 Z |
Milki |
Dreaming (IOI13_dreaming) |
C++14 |
|
165 ms |
18536 KB |
//#ifndef DREAMING_H_INCLUDED
//#define DREAMING_H_INCLUDED
#include "dreaming.h"
#include<bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for(int i = a; i < b; ++i)
#define REP(i, n) FOR(i, 0, n)
#define _ << " " <<
#define sz(x) ((int) x.size())
#define pb(x) push_back(x)
#define TRACE(x) cerr << #x << " = " << x << endl
typedef long long ll;
typedef pair<ll, ll> point;
const ll MAXN = 1e5 + 5;
vector <point> E[MAXN];
vector <ll> component[MAXN];
ll boja[MAXN], dist[MAXN], dep[MAXN], mx[MAXN];
point par[MAXN];
void color(ll x, ll Time){
boja[x] = Time;
component[Time].pb(x);
for(auto e : E[x]){
if(boja[e.first] != ll(-1) ) continue;
color(e.first, Time);
}
}
point find_furthest(ll cmp, ll x){
for(auto it : component[cmp])
dist[it] = 0;
queue<ll> Q;
Q.push(x);
point ret = point(0, 0);
while(!Q.empty()){
ll nx = Q.front(); Q.pop();
for(auto e : E[nx]){
if(dist[e.first] || e.first == x)
continue;
par[e.first] = point(nx, e.second);
dep[e.first] = dep[nx] + 1;
dist[e.first] = dist[nx] + e.second;
ret = max(ret, point(dist[e.first], e.first));
Q.push(e.first);
}
}
return ret;
}
int travelTime(int N, int M, int L, int A[], int B[], int T[]) {
REP(i, M){
E[ A[i] ].pb( point( B[i], T[i] ) );
E[ B[i] ].pb( point( A[i], T[i] ) );
}
memset(boja, -1, sizeof(boja));
ll Time = 0;
REP(i, N)
if(boja[i] == -1)
color(i, Time ++);
ll ret = 0;
REP(i, Time){
ll a = find_furthest(i, component[i][0]).second;
point najdalji = find_furthest(i, a);
ll b = najdalji.second, d = najdalji.first;
if(dep[a] < dep[b])
swap(a, b);
ret = max(ret, d);
mx[i] = d;
ll sum = 0;
while(dep[a] != dep[b]){
sum += par[a].second;
a = par[a].first;
mx[i] = min(mx[i], max(d - sum, sum));
}
deque<ll> lt, rt;
while(a != b){
lt.push_back(par[a].second);
a = par[a].first;
rt.push_front(par[b].second);
b = par[b].first;
}
for(auto it : lt){
sum += it;
mx[i] = min(mx[i], max(d - sum, sum));
}
for(auto it : rt){
sum += it;
mx[i] = min(mx[i], max(d - sum, sum));
}
}
sort(mx, mx + Time, greater<ll>());
if(Time == 1)
return ret;
else
return max(ret, mx[0] + mx[1] + L);
}
//#endif // DREAMING_H_INCLUDED
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
84 ms |
18536 KB |
Output is correct |
2 |
Correct |
95 ms |
18284 KB |
Output is correct |
3 |
Correct |
54 ms |
15216 KB |
Output is correct |
4 |
Correct |
17 ms |
7800 KB |
Output is correct |
5 |
Correct |
15 ms |
7288 KB |
Output is correct |
6 |
Correct |
25 ms |
8908 KB |
Output is correct |
7 |
Correct |
7 ms |
5880 KB |
Output is correct |
8 |
Correct |
44 ms |
11636 KB |
Output is correct |
9 |
Correct |
57 ms |
13680 KB |
Output is correct |
10 |
Correct |
7 ms |
6008 KB |
Output is correct |
11 |
Correct |
89 ms |
16032 KB |
Output is correct |
12 |
Correct |
96 ms |
17328 KB |
Output is correct |
13 |
Correct |
7 ms |
6008 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
84 ms |
18536 KB |
Output is correct |
2 |
Correct |
95 ms |
18284 KB |
Output is correct |
3 |
Correct |
54 ms |
15216 KB |
Output is correct |
4 |
Correct |
17 ms |
7800 KB |
Output is correct |
5 |
Correct |
15 ms |
7288 KB |
Output is correct |
6 |
Correct |
25 ms |
8908 KB |
Output is correct |
7 |
Correct |
7 ms |
5880 KB |
Output is correct |
8 |
Correct |
44 ms |
11636 KB |
Output is correct |
9 |
Correct |
57 ms |
13680 KB |
Output is correct |
10 |
Correct |
7 ms |
6008 KB |
Output is correct |
11 |
Correct |
89 ms |
16032 KB |
Output is correct |
12 |
Correct |
96 ms |
17328 KB |
Output is correct |
13 |
Correct |
7 ms |
6008 KB |
Output is correct |
14 |
Correct |
7 ms |
5880 KB |
Output is correct |
15 |
Correct |
7 ms |
5880 KB |
Output is correct |
16 |
Correct |
7 ms |
5884 KB |
Output is correct |
17 |
Correct |
7 ms |
5880 KB |
Output is correct |
18 |
Correct |
7 ms |
5884 KB |
Output is correct |
19 |
Correct |
7 ms |
5880 KB |
Output is correct |
20 |
Correct |
7 ms |
5880 KB |
Output is correct |
21 |
Correct |
7 ms |
5880 KB |
Output is correct |
22 |
Correct |
7 ms |
5884 KB |
Output is correct |
23 |
Correct |
7 ms |
5880 KB |
Output is correct |
24 |
Correct |
7 ms |
5880 KB |
Output is correct |
25 |
Correct |
6 ms |
5880 KB |
Output is correct |
26 |
Correct |
7 ms |
5880 KB |
Output is correct |
27 |
Correct |
7 ms |
5880 KB |
Output is correct |
28 |
Correct |
7 ms |
5880 KB |
Output is correct |
29 |
Correct |
7 ms |
5880 KB |
Output is correct |
30 |
Correct |
7 ms |
5880 KB |
Output is correct |
31 |
Correct |
7 ms |
5884 KB |
Output is correct |
32 |
Correct |
7 ms |
5880 KB |
Output is correct |
33 |
Correct |
7 ms |
5880 KB |
Output is correct |
34 |
Correct |
7 ms |
5880 KB |
Output is correct |
35 |
Correct |
7 ms |
5880 KB |
Output is correct |
36 |
Correct |
7 ms |
5880 KB |
Output is correct |
37 |
Correct |
6 ms |
5880 KB |
Output is correct |
38 |
Correct |
7 ms |
5880 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
84 ms |
18536 KB |
Output is correct |
2 |
Correct |
95 ms |
18284 KB |
Output is correct |
3 |
Correct |
54 ms |
15216 KB |
Output is correct |
4 |
Correct |
17 ms |
7800 KB |
Output is correct |
5 |
Correct |
15 ms |
7288 KB |
Output is correct |
6 |
Correct |
25 ms |
8908 KB |
Output is correct |
7 |
Correct |
7 ms |
5880 KB |
Output is correct |
8 |
Correct |
44 ms |
11636 KB |
Output is correct |
9 |
Correct |
57 ms |
13680 KB |
Output is correct |
10 |
Correct |
7 ms |
6008 KB |
Output is correct |
11 |
Correct |
89 ms |
16032 KB |
Output is correct |
12 |
Correct |
96 ms |
17328 KB |
Output is correct |
13 |
Correct |
7 ms |
6008 KB |
Output is correct |
14 |
Correct |
7 ms |
5880 KB |
Output is correct |
15 |
Correct |
7 ms |
5880 KB |
Output is correct |
16 |
Correct |
7 ms |
5884 KB |
Output is correct |
17 |
Correct |
7 ms |
5880 KB |
Output is correct |
18 |
Correct |
7 ms |
5884 KB |
Output is correct |
19 |
Correct |
7 ms |
5880 KB |
Output is correct |
20 |
Correct |
7 ms |
5880 KB |
Output is correct |
21 |
Correct |
7 ms |
5880 KB |
Output is correct |
22 |
Correct |
7 ms |
5884 KB |
Output is correct |
23 |
Correct |
7 ms |
5880 KB |
Output is correct |
24 |
Correct |
7 ms |
5880 KB |
Output is correct |
25 |
Correct |
6 ms |
5880 KB |
Output is correct |
26 |
Correct |
7 ms |
5880 KB |
Output is correct |
27 |
Correct |
7 ms |
5880 KB |
Output is correct |
28 |
Correct |
7 ms |
5880 KB |
Output is correct |
29 |
Correct |
7 ms |
5880 KB |
Output is correct |
30 |
Correct |
7 ms |
5880 KB |
Output is correct |
31 |
Correct |
7 ms |
5884 KB |
Output is correct |
32 |
Correct |
7 ms |
5880 KB |
Output is correct |
33 |
Correct |
7 ms |
5880 KB |
Output is correct |
34 |
Correct |
7 ms |
5880 KB |
Output is correct |
35 |
Correct |
7 ms |
5880 KB |
Output is correct |
36 |
Correct |
7 ms |
5880 KB |
Output is correct |
37 |
Correct |
6 ms |
5880 KB |
Output is correct |
38 |
Correct |
7 ms |
5880 KB |
Output is correct |
39 |
Correct |
98 ms |
18456 KB |
Output is correct |
40 |
Correct |
103 ms |
18280 KB |
Output is correct |
41 |
Correct |
55 ms |
15216 KB |
Output is correct |
42 |
Correct |
20 ms |
7792 KB |
Output is correct |
43 |
Correct |
7 ms |
5880 KB |
Output is correct |
44 |
Correct |
7 ms |
5880 KB |
Output is correct |
45 |
Correct |
7 ms |
5780 KB |
Output is correct |
46 |
Correct |
7 ms |
5880 KB |
Output is correct |
47 |
Correct |
8 ms |
5880 KB |
Output is correct |
48 |
Correct |
8 ms |
5880 KB |
Output is correct |
49 |
Correct |
9 ms |
5880 KB |
Output is correct |
50 |
Correct |
8 ms |
5880 KB |
Output is correct |
51 |
Correct |
7 ms |
5880 KB |
Output is correct |
52 |
Correct |
7 ms |
5880 KB |
Output is correct |
53 |
Correct |
7 ms |
5880 KB |
Output is correct |
54 |
Correct |
7 ms |
5880 KB |
Output is correct |
55 |
Correct |
7 ms |
5880 KB |
Output is correct |
56 |
Correct |
7 ms |
5880 KB |
Output is correct |
57 |
Correct |
121 ms |
18284 KB |
Output is correct |
58 |
Correct |
165 ms |
18400 KB |
Output is correct |
59 |
Correct |
107 ms |
18056 KB |
Output is correct |
60 |
Correct |
110 ms |
18008 KB |
Output is correct |
61 |
Correct |
111 ms |
18028 KB |
Output is correct |
62 |
Correct |
107 ms |
18036 KB |
Output is correct |
63 |
Correct |
108 ms |
17640 KB |
Output is correct |
64 |
Incorrect |
131 ms |
17512 KB |
Output isn't correct |
65 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
87 ms |
13944 KB |
Output is correct |
2 |
Incorrect |
84 ms |
13944 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
84 ms |
18536 KB |
Output is correct |
2 |
Correct |
95 ms |
18284 KB |
Output is correct |
3 |
Correct |
54 ms |
15216 KB |
Output is correct |
4 |
Correct |
17 ms |
7800 KB |
Output is correct |
5 |
Correct |
15 ms |
7288 KB |
Output is correct |
6 |
Correct |
25 ms |
8908 KB |
Output is correct |
7 |
Correct |
7 ms |
5880 KB |
Output is correct |
8 |
Correct |
44 ms |
11636 KB |
Output is correct |
9 |
Correct |
57 ms |
13680 KB |
Output is correct |
10 |
Correct |
7 ms |
6008 KB |
Output is correct |
11 |
Correct |
89 ms |
16032 KB |
Output is correct |
12 |
Correct |
96 ms |
17328 KB |
Output is correct |
13 |
Correct |
7 ms |
6008 KB |
Output is correct |
14 |
Correct |
7 ms |
6008 KB |
Output is correct |
15 |
Correct |
8 ms |
6008 KB |
Output is correct |
16 |
Correct |
9 ms |
6136 KB |
Output is correct |
17 |
Correct |
7 ms |
6008 KB |
Output is correct |
18 |
Correct |
8 ms |
6008 KB |
Output is correct |
19 |
Correct |
9 ms |
6136 KB |
Output is correct |
20 |
Incorrect |
7 ms |
6008 KB |
Output isn't correct |
21 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
84 ms |
18536 KB |
Output is correct |
2 |
Correct |
95 ms |
18284 KB |
Output is correct |
3 |
Correct |
54 ms |
15216 KB |
Output is correct |
4 |
Correct |
17 ms |
7800 KB |
Output is correct |
5 |
Correct |
15 ms |
7288 KB |
Output is correct |
6 |
Correct |
25 ms |
8908 KB |
Output is correct |
7 |
Correct |
7 ms |
5880 KB |
Output is correct |
8 |
Correct |
44 ms |
11636 KB |
Output is correct |
9 |
Correct |
57 ms |
13680 KB |
Output is correct |
10 |
Correct |
7 ms |
6008 KB |
Output is correct |
11 |
Correct |
89 ms |
16032 KB |
Output is correct |
12 |
Correct |
96 ms |
17328 KB |
Output is correct |
13 |
Correct |
7 ms |
6008 KB |
Output is correct |
14 |
Correct |
7 ms |
5880 KB |
Output is correct |
15 |
Correct |
7 ms |
5880 KB |
Output is correct |
16 |
Correct |
7 ms |
5884 KB |
Output is correct |
17 |
Correct |
7 ms |
5880 KB |
Output is correct |
18 |
Correct |
7 ms |
5884 KB |
Output is correct |
19 |
Correct |
7 ms |
5880 KB |
Output is correct |
20 |
Correct |
7 ms |
5880 KB |
Output is correct |
21 |
Correct |
7 ms |
5880 KB |
Output is correct |
22 |
Correct |
7 ms |
5884 KB |
Output is correct |
23 |
Correct |
7 ms |
5880 KB |
Output is correct |
24 |
Correct |
7 ms |
5880 KB |
Output is correct |
25 |
Correct |
6 ms |
5880 KB |
Output is correct |
26 |
Correct |
7 ms |
5880 KB |
Output is correct |
27 |
Correct |
7 ms |
5880 KB |
Output is correct |
28 |
Correct |
7 ms |
5880 KB |
Output is correct |
29 |
Correct |
7 ms |
5880 KB |
Output is correct |
30 |
Correct |
7 ms |
5880 KB |
Output is correct |
31 |
Correct |
7 ms |
5884 KB |
Output is correct |
32 |
Correct |
7 ms |
5880 KB |
Output is correct |
33 |
Correct |
7 ms |
5880 KB |
Output is correct |
34 |
Correct |
7 ms |
5880 KB |
Output is correct |
35 |
Correct |
7 ms |
5880 KB |
Output is correct |
36 |
Correct |
7 ms |
5880 KB |
Output is correct |
37 |
Correct |
6 ms |
5880 KB |
Output is correct |
38 |
Correct |
7 ms |
5880 KB |
Output is correct |
39 |
Correct |
98 ms |
18456 KB |
Output is correct |
40 |
Correct |
103 ms |
18280 KB |
Output is correct |
41 |
Correct |
55 ms |
15216 KB |
Output is correct |
42 |
Correct |
20 ms |
7792 KB |
Output is correct |
43 |
Correct |
7 ms |
5880 KB |
Output is correct |
44 |
Correct |
7 ms |
5880 KB |
Output is correct |
45 |
Correct |
7 ms |
5780 KB |
Output is correct |
46 |
Correct |
7 ms |
5880 KB |
Output is correct |
47 |
Correct |
8 ms |
5880 KB |
Output is correct |
48 |
Correct |
8 ms |
5880 KB |
Output is correct |
49 |
Correct |
9 ms |
5880 KB |
Output is correct |
50 |
Correct |
8 ms |
5880 KB |
Output is correct |
51 |
Correct |
7 ms |
5880 KB |
Output is correct |
52 |
Correct |
7 ms |
5880 KB |
Output is correct |
53 |
Correct |
7 ms |
5880 KB |
Output is correct |
54 |
Correct |
7 ms |
5880 KB |
Output is correct |
55 |
Correct |
7 ms |
5880 KB |
Output is correct |
56 |
Correct |
7 ms |
5880 KB |
Output is correct |
57 |
Correct |
121 ms |
18284 KB |
Output is correct |
58 |
Correct |
165 ms |
18400 KB |
Output is correct |
59 |
Correct |
107 ms |
18056 KB |
Output is correct |
60 |
Correct |
110 ms |
18008 KB |
Output is correct |
61 |
Correct |
111 ms |
18028 KB |
Output is correct |
62 |
Correct |
107 ms |
18036 KB |
Output is correct |
63 |
Correct |
108 ms |
17640 KB |
Output is correct |
64 |
Incorrect |
131 ms |
17512 KB |
Output isn't correct |
65 |
Halted |
0 ms |
0 KB |
- |