답안 #103238

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
103238 2019-03-29T09:48:09 Z dimash241 꿈 (IOI13_dreaming) C++17
24 / 100
117 ms 24196 KB
#include "dreaming.h"
#include <bits/stdc++.h>
 
#define _USE_MATH_DEFINES_
#define ll long long
#define ld long double
#define Accepted 0
#define pb push_back
#define mp make_pair
#define sz(x) (int)(x.size())
#define every(x) x.begin(),x.end()
#define F first
#define S second
#define For(i,x,y)  for (ll i = x; i <= y; i ++) 
#define FOr(i,x,y)  for (ll i = x; i >= y; i --)
#define SpeedForce ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
// ROAD to...                                                                                                                                                                                                                Red
 
using namespace std;
 
const double eps = 0.000001;
const ld pi = acos(-1);
const int maxn = 1e7 + 9;
const int mod = 1e9 + 7;
const ll MOD = 1e18 + 9;
const ll INF = 1e18 + 123;
const int inf = 2e9 + 11;
const int mxn = 1e6 + 9;
const int N = 6e5 + 123;                                          
const int M = 22;
const int pri = 997;
const int Magic = 2101;
 
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};
 
vector < int > comp;
vector < pair < int, int > > g[N];
int n, m, k;
int u[N];
int p[N];
int col;
int dp[N];
int h[N];
int ans;

void dfs (int v, int par = 0) {
	u[v] = 1;
	comp.pb(v);
	for (auto to : g[v]) {
		if (to.F != par) {
			h[to.F] = h[v] + to.S;
			p[to.F] = v;
			dfs(to.F, v);
		}
	}
} 
int travelTime(int N, int M, int L, int A[], int B[], int T[]) {
	n = N, m = M, k = L;
	for (int i = 1; i <= m; i ++) {
		int l, r, x;
		l = A[i - 1], r = B[i - 1], x = T[i - 1]; 
		g[l].pb(mp(r, x));
		g[r].pb(mp(l, x));
	}
	int ans = 0;
	vector < int > vv;
	for (int i = 0; i < n; i ++) {
		if (!u[i]) {
			col ++;
			p[i] = -1;
			comp.clear();
			h[i] = 0;
			dfs (i);
			int mx = i;
			for (auto e : comp)
				if (h[e] > h[mx]) mx = e;
			p[mx] = -1;
			comp.clear();
			h[mx] = 0;
			dfs(mx);
			for (auto e : comp)
				if (h[e] > h[mx]) mx = e;
			ans = max(ans, h[mx]);
			//cout << mx << ' ' << h[mx] << '\n';
			int half = h[mx];
			for (int v = mx; ~v; v = p[v]) {
				half = min(half, max(h[v], abs(h[v] - h[mx])));
			}
			vv.pb(half);
		}
	}
	sort(every(vv));
	reverse(every(vv));
	if (vv.size() >= 2)
		ans = max(ans, vv[0] + vv[1] + k);
	return ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 72 ms 24180 KB Output is correct
2 Correct 72 ms 24180 KB Output is correct
3 Correct 52 ms 20852 KB Output is correct
4 Correct 21 ms 15872 KB Output is correct
5 Correct 21 ms 15232 KB Output is correct
6 Correct 27 ms 16640 KB Output is correct
7 Correct 15 ms 14592 KB Output is correct
8 Correct 41 ms 18040 KB Output is correct
9 Correct 49 ms 19340 KB Output is correct
10 Correct 14 ms 14464 KB Output is correct
11 Correct 66 ms 20856 KB Output is correct
12 Correct 91 ms 22484 KB Output is correct
13 Correct 13 ms 14464 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 72 ms 24180 KB Output is correct
2 Correct 72 ms 24180 KB Output is correct
3 Correct 52 ms 20852 KB Output is correct
4 Correct 21 ms 15872 KB Output is correct
5 Correct 21 ms 15232 KB Output is correct
6 Correct 27 ms 16640 KB Output is correct
7 Correct 15 ms 14592 KB Output is correct
8 Correct 41 ms 18040 KB Output is correct
9 Correct 49 ms 19340 KB Output is correct
10 Correct 14 ms 14464 KB Output is correct
11 Correct 66 ms 20856 KB Output is correct
12 Correct 91 ms 22484 KB Output is correct
13 Correct 13 ms 14464 KB Output is correct
14 Correct 14 ms 14464 KB Output is correct
15 Correct 14 ms 14464 KB Output is correct
16 Correct 19 ms 14464 KB Output is correct
17 Correct 14 ms 14464 KB Output is correct
18 Correct 13 ms 14464 KB Output is correct
19 Correct 14 ms 14464 KB Output is correct
20 Correct 14 ms 14464 KB Output is correct
21 Correct 14 ms 14560 KB Output is correct
22 Correct 14 ms 14464 KB Output is correct
23 Correct 13 ms 14464 KB Output is correct
24 Correct 14 ms 14464 KB Output is correct
25 Correct 13 ms 14464 KB Output is correct
26 Correct 14 ms 14464 KB Output is correct
27 Correct 13 ms 14464 KB Output is correct
28 Correct 14 ms 14464 KB Output is correct
29 Correct 13 ms 14464 KB Output is correct
30 Correct 14 ms 14464 KB Output is correct
31 Correct 13 ms 14592 KB Output is correct
32 Correct 13 ms 14464 KB Output is correct
33 Correct 14 ms 14464 KB Output is correct
34 Correct 14 ms 14464 KB Output is correct
35 Correct 14 ms 14464 KB Output is correct
36 Correct 14 ms 14464 KB Output is correct
37 Correct 14 ms 14464 KB Output is correct
38 Correct 14 ms 14464 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 72 ms 24180 KB Output is correct
2 Correct 72 ms 24180 KB Output is correct
3 Correct 52 ms 20852 KB Output is correct
4 Correct 21 ms 15872 KB Output is correct
5 Correct 21 ms 15232 KB Output is correct
6 Correct 27 ms 16640 KB Output is correct
7 Correct 15 ms 14592 KB Output is correct
8 Correct 41 ms 18040 KB Output is correct
9 Correct 49 ms 19340 KB Output is correct
10 Correct 14 ms 14464 KB Output is correct
11 Correct 66 ms 20856 KB Output is correct
12 Correct 91 ms 22484 KB Output is correct
13 Correct 13 ms 14464 KB Output is correct
14 Correct 14 ms 14464 KB Output is correct
15 Correct 14 ms 14464 KB Output is correct
16 Correct 19 ms 14464 KB Output is correct
17 Correct 14 ms 14464 KB Output is correct
18 Correct 13 ms 14464 KB Output is correct
19 Correct 14 ms 14464 KB Output is correct
20 Correct 14 ms 14464 KB Output is correct
21 Correct 14 ms 14560 KB Output is correct
22 Correct 14 ms 14464 KB Output is correct
23 Correct 13 ms 14464 KB Output is correct
24 Correct 14 ms 14464 KB Output is correct
25 Correct 13 ms 14464 KB Output is correct
26 Correct 14 ms 14464 KB Output is correct
27 Correct 13 ms 14464 KB Output is correct
28 Correct 14 ms 14464 KB Output is correct
29 Correct 13 ms 14464 KB Output is correct
30 Correct 14 ms 14464 KB Output is correct
31 Correct 13 ms 14592 KB Output is correct
32 Correct 13 ms 14464 KB Output is correct
33 Correct 14 ms 14464 KB Output is correct
34 Correct 14 ms 14464 KB Output is correct
35 Correct 14 ms 14464 KB Output is correct
36 Correct 14 ms 14464 KB Output is correct
37 Correct 14 ms 14464 KB Output is correct
38 Correct 14 ms 14464 KB Output is correct
39 Correct 79 ms 24196 KB Output is correct
40 Correct 75 ms 24180 KB Output is correct
41 Correct 53 ms 20924 KB Output is correct
42 Correct 21 ms 16000 KB Output is correct
43 Correct 13 ms 14464 KB Output is correct
44 Correct 13 ms 14464 KB Output is correct
45 Correct 13 ms 14464 KB Output is correct
46 Correct 12 ms 14464 KB Output is correct
47 Correct 13 ms 14464 KB Output is correct
48 Correct 13 ms 14464 KB Output is correct
49 Correct 13 ms 14464 KB Output is correct
50 Correct 13 ms 14492 KB Output is correct
51 Correct 13 ms 14464 KB Output is correct
52 Correct 14 ms 14392 KB Output is correct
53 Correct 13 ms 14464 KB Output is correct
54 Correct 14 ms 14464 KB Output is correct
55 Correct 13 ms 14464 KB Output is correct
56 Correct 15 ms 14464 KB Output is correct
57 Correct 92 ms 21492 KB Output is correct
58 Correct 101 ms 21288 KB Output is correct
59 Correct 115 ms 21344 KB Output is correct
60 Correct 117 ms 21132 KB Output is correct
61 Correct 89 ms 21292 KB Output is correct
62 Correct 89 ms 20956 KB Output is correct
63 Correct 88 ms 21112 KB Output is correct
64 Incorrect 82 ms 21112 KB Output isn't correct
65 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 52 ms 18296 KB Output is correct
2 Incorrect 40 ms 18296 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 72 ms 24180 KB Output is correct
2 Correct 72 ms 24180 KB Output is correct
3 Correct 52 ms 20852 KB Output is correct
4 Correct 21 ms 15872 KB Output is correct
5 Correct 21 ms 15232 KB Output is correct
6 Correct 27 ms 16640 KB Output is correct
7 Correct 15 ms 14592 KB Output is correct
8 Correct 41 ms 18040 KB Output is correct
9 Correct 49 ms 19340 KB Output is correct
10 Correct 14 ms 14464 KB Output is correct
11 Correct 66 ms 20856 KB Output is correct
12 Correct 91 ms 22484 KB Output is correct
13 Correct 13 ms 14464 KB Output is correct
14 Correct 15 ms 14464 KB Output is correct
15 Correct 14 ms 14592 KB Output is correct
16 Correct 14 ms 14592 KB Output is correct
17 Correct 13 ms 14464 KB Output is correct
18 Correct 14 ms 14592 KB Output is correct
19 Correct 15 ms 14592 KB Output is correct
20 Incorrect 14 ms 14464 KB Output isn't correct
21 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 72 ms 24180 KB Output is correct
2 Correct 72 ms 24180 KB Output is correct
3 Correct 52 ms 20852 KB Output is correct
4 Correct 21 ms 15872 KB Output is correct
5 Correct 21 ms 15232 KB Output is correct
6 Correct 27 ms 16640 KB Output is correct
7 Correct 15 ms 14592 KB Output is correct
8 Correct 41 ms 18040 KB Output is correct
9 Correct 49 ms 19340 KB Output is correct
10 Correct 14 ms 14464 KB Output is correct
11 Correct 66 ms 20856 KB Output is correct
12 Correct 91 ms 22484 KB Output is correct
13 Correct 13 ms 14464 KB Output is correct
14 Correct 14 ms 14464 KB Output is correct
15 Correct 14 ms 14464 KB Output is correct
16 Correct 19 ms 14464 KB Output is correct
17 Correct 14 ms 14464 KB Output is correct
18 Correct 13 ms 14464 KB Output is correct
19 Correct 14 ms 14464 KB Output is correct
20 Correct 14 ms 14464 KB Output is correct
21 Correct 14 ms 14560 KB Output is correct
22 Correct 14 ms 14464 KB Output is correct
23 Correct 13 ms 14464 KB Output is correct
24 Correct 14 ms 14464 KB Output is correct
25 Correct 13 ms 14464 KB Output is correct
26 Correct 14 ms 14464 KB Output is correct
27 Correct 13 ms 14464 KB Output is correct
28 Correct 14 ms 14464 KB Output is correct
29 Correct 13 ms 14464 KB Output is correct
30 Correct 14 ms 14464 KB Output is correct
31 Correct 13 ms 14592 KB Output is correct
32 Correct 13 ms 14464 KB Output is correct
33 Correct 14 ms 14464 KB Output is correct
34 Correct 14 ms 14464 KB Output is correct
35 Correct 14 ms 14464 KB Output is correct
36 Correct 14 ms 14464 KB Output is correct
37 Correct 14 ms 14464 KB Output is correct
38 Correct 14 ms 14464 KB Output is correct
39 Correct 79 ms 24196 KB Output is correct
40 Correct 75 ms 24180 KB Output is correct
41 Correct 53 ms 20924 KB Output is correct
42 Correct 21 ms 16000 KB Output is correct
43 Correct 13 ms 14464 KB Output is correct
44 Correct 13 ms 14464 KB Output is correct
45 Correct 13 ms 14464 KB Output is correct
46 Correct 12 ms 14464 KB Output is correct
47 Correct 13 ms 14464 KB Output is correct
48 Correct 13 ms 14464 KB Output is correct
49 Correct 13 ms 14464 KB Output is correct
50 Correct 13 ms 14492 KB Output is correct
51 Correct 13 ms 14464 KB Output is correct
52 Correct 14 ms 14392 KB Output is correct
53 Correct 13 ms 14464 KB Output is correct
54 Correct 14 ms 14464 KB Output is correct
55 Correct 13 ms 14464 KB Output is correct
56 Correct 15 ms 14464 KB Output is correct
57 Correct 92 ms 21492 KB Output is correct
58 Correct 101 ms 21288 KB Output is correct
59 Correct 115 ms 21344 KB Output is correct
60 Correct 117 ms 21132 KB Output is correct
61 Correct 89 ms 21292 KB Output is correct
62 Correct 89 ms 20956 KB Output is correct
63 Correct 88 ms 21112 KB Output is correct
64 Incorrect 82 ms 21112 KB Output isn't correct
65 Halted 0 ms 0 KB -