답안 #932405

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
932405 2024-02-23T09:39:51 Z pan 꿈 (IOI13_dreaming) C++17
59 / 100
1000 ms 17864 KB
#include "dreaming.h"
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//#include "bits_stdc++.h"
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define input(x) scanf("%lld", &x);
#define input2(x, y) scanf("%lld%lld", &x, &y);
#define input3(x, y, z) scanf("%lld%lld%lld", &x, &y, &z);
#define input4(x, y, z, a) scanf("%lld%lld%lld%lld", &x, &y, &z, &a);
#define print(x, y) printf("%lld%c", x, y);
#define show(x) cerr << #x << " is " << x << endl;
#define show2(x,y) cerr << #x << " is " << x << " " << #y << " is " << y << endl;
#define show3(x,y,z) cerr << #x << " is " << x << " " << #y << " is " << y << " " << #z << " is " << z << endl;
#define discretize(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
using namespace std;
//using namespace __gnu_pbds;
//#define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
//#define ordered_multiset tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update>
typedef long long ll;
typedef long double ld;
typedef pair<ld, ll> pd;
typedef pair<string, ll> psl;
typedef pair<ll, ll> pi;
typedef pair<ll, pi> pii;
ll n, m, l, counter = 0, farest, dis, dia = 0;
ll const INF =1e13;
vector<ll> radii;
vector<pi> adj[100005];
vector<ll> dist(100005, -1);
vector<ll> visited;
bool joined[100005];
vector<ll> cc;
void dfs(ll from)
{
	if (!joined[from])  cc.pb(from);
	joined[from] = true;
	visited[from] = true;
	for (pi u: adj[from])
	{
		if (visited[u.f] ) continue;
		visited[u.f] = true;
		dist[u.f] = dist[from] + u.s;
		if (dist[u.f]>dis) {dis= dist[u.f], farest = u.f;}
		dfs(u.f);
	}
	
}
void reset() 
{
	visited.assign(n, false);
	dist.assign(100005, INF);
}
int travelTime(int N, int M, int L, int A[], int B[], int T[])
{
	n = N, m = M, l = L;
	for (ll i=0; i<m; ++i)
	{
		adj[A[i]].pb(mp(B[i], T[i]));
		adj[B[i]].pb(mp(A[i], T[i]));
	}
	for (ll i=0; i<n; ++i)
	{
		if (joined[i]) continue;
		counter++;
		cc.clear();
		reset();
		dist[i] = 0;
		farest = i;
		dis= 0 ;
		dfs(i);
		ll first = farest;
		reset();
		dist[first] = 0;
		dis=0;
		farest = first;
		dfs(first);
		ll second = farest;
		vector<ll> dist1= dist;
		dia = max(dia, dis);
		reset();
		dist[second] = 0;
		dfs(second);
		vector<ll> dist2 = dist;
		ll radius = LLONG_MAX/2;
		for (ll j=0; j<ll(cc.size()); ++j)
		{
			radius = min(radius, max(dist1[cc[j]], dist2[cc[j]]));
		}
		radii.pb(radius);
	}
	if (n==1) return 0;
	if (n==2) return (m==1)?dia:l;
	sort(radii.begin(), radii.end(), greater<ll>());
	ll ans = dia;
	if (counter>1) ans = max(ans, radii[0] + radii[1]+ l);
	if (counter>2) ans = max(ans, radii[1] + radii[2]+ 2*l);
	return ans;
	return 0;
}


# 결과 실행 시간 메모리 Grader output
1 Correct 37 ms 16872 KB Output is correct
2 Correct 48 ms 16584 KB Output is correct
3 Correct 26 ms 13116 KB Output is correct
4 Correct 10 ms 7768 KB Output is correct
5 Correct 7 ms 7260 KB Output is correct
6 Correct 12 ms 8676 KB Output is correct
7 Correct 3 ms 6236 KB Output is correct
8 Correct 20 ms 10216 KB Output is correct
9 Correct 25 ms 11668 KB Output is correct
10 Correct 3 ms 6236 KB Output is correct
11 Correct 38 ms 13296 KB Output is correct
12 Correct 45 ms 15112 KB Output is correct
13 Correct 3 ms 6232 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 6236 KB Output is correct
2 Correct 3 ms 6180 KB Output is correct
3 Correct 3 ms 6236 KB Output is correct
4 Correct 3 ms 6232 KB Output is correct
5 Correct 3 ms 6124 KB Output is correct
6 Correct 3 ms 6232 KB Output is correct
7 Correct 3 ms 6236 KB Output is correct
8 Correct 3 ms 6236 KB Output is correct
9 Correct 3 ms 6236 KB Output is correct
10 Correct 3 ms 6236 KB Output is correct
11 Correct 3 ms 6236 KB Output is correct
12 Correct 3 ms 6236 KB Output is correct
13 Correct 3 ms 6236 KB Output is correct
14 Correct 3 ms 6236 KB Output is correct
15 Correct 3 ms 6236 KB Output is correct
16 Correct 3 ms 6236 KB Output is correct
17 Correct 4 ms 6260 KB Output is correct
18 Correct 3 ms 6236 KB Output is correct
19 Correct 3 ms 6236 KB Output is correct
20 Correct 3 ms 6236 KB Output is correct
21 Correct 3 ms 6236 KB Output is correct
22 Correct 3 ms 6236 KB Output is correct
23 Correct 3 ms 6236 KB Output is correct
24 Correct 3 ms 6236 KB Output is correct
25 Correct 3 ms 6236 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 37 ms 16872 KB Output is correct
2 Correct 48 ms 16584 KB Output is correct
3 Correct 26 ms 13116 KB Output is correct
4 Correct 10 ms 7768 KB Output is correct
5 Correct 7 ms 7260 KB Output is correct
6 Correct 12 ms 8676 KB Output is correct
7 Correct 3 ms 6236 KB Output is correct
8 Correct 20 ms 10216 KB Output is correct
9 Correct 25 ms 11668 KB Output is correct
10 Correct 3 ms 6236 KB Output is correct
11 Correct 38 ms 13296 KB Output is correct
12 Correct 45 ms 15112 KB Output is correct
13 Correct 3 ms 6232 KB Output is correct
14 Correct 4 ms 6236 KB Output is correct
15 Correct 3 ms 6180 KB Output is correct
16 Correct 3 ms 6236 KB Output is correct
17 Correct 3 ms 6232 KB Output is correct
18 Correct 3 ms 6124 KB Output is correct
19 Correct 3 ms 6232 KB Output is correct
20 Correct 3 ms 6236 KB Output is correct
21 Correct 3 ms 6236 KB Output is correct
22 Correct 3 ms 6236 KB Output is correct
23 Correct 3 ms 6236 KB Output is correct
24 Correct 3 ms 6236 KB Output is correct
25 Correct 3 ms 6236 KB Output is correct
26 Correct 3 ms 6236 KB Output is correct
27 Correct 3 ms 6236 KB Output is correct
28 Correct 3 ms 6236 KB Output is correct
29 Correct 3 ms 6236 KB Output is correct
30 Correct 4 ms 6260 KB Output is correct
31 Correct 3 ms 6236 KB Output is correct
32 Correct 3 ms 6236 KB Output is correct
33 Correct 3 ms 6236 KB Output is correct
34 Correct 3 ms 6236 KB Output is correct
35 Correct 3 ms 6236 KB Output is correct
36 Correct 3 ms 6236 KB Output is correct
37 Correct 3 ms 6236 KB Output is correct
38 Correct 3 ms 6236 KB Output is correct
39 Correct 36 ms 16516 KB Output is correct
40 Correct 38 ms 16636 KB Output is correct
41 Correct 33 ms 13264 KB Output is correct
42 Correct 8 ms 7768 KB Output is correct
43 Correct 3 ms 6236 KB Output is correct
44 Correct 3 ms 6236 KB Output is correct
45 Correct 3 ms 6236 KB Output is correct
46 Correct 3 ms 6236 KB Output is correct
47 Correct 3 ms 6224 KB Output is correct
48 Correct 3 ms 6236 KB Output is correct
49 Correct 3 ms 6236 KB Output is correct
50 Correct 3 ms 6236 KB Output is correct
51 Correct 3 ms 6236 KB Output is correct
52 Correct 3 ms 6232 KB Output is correct
53 Correct 3 ms 6232 KB Output is correct
54 Correct 3 ms 6236 KB Output is correct
55 Correct 3 ms 6236 KB Output is correct
56 Correct 3 ms 6232 KB Output is correct
57 Correct 51 ms 14176 KB Output is correct
58 Correct 50 ms 13872 KB Output is correct
59 Correct 57 ms 13776 KB Output is correct
60 Correct 49 ms 13496 KB Output is correct
61 Correct 58 ms 13792 KB Output is correct
62 Correct 45 ms 13352 KB Output is correct
63 Correct 47 ms 13444 KB Output is correct
64 Correct 44 ms 13512 KB Output is correct
65 Correct 46 ms 13760 KB Output is correct
66 Correct 48 ms 13764 KB Output is correct
67 Correct 51 ms 14028 KB Output is correct
68 Correct 50 ms 13556 KB Output is correct
69 Correct 54 ms 13744 KB Output is correct
70 Correct 55 ms 14032 KB Output is correct
71 Correct 3 ms 6232 KB Output is correct
72 Correct 4 ms 6492 KB Output is correct
73 Correct 4 ms 6492 KB Output is correct
74 Correct 4 ms 6492 KB Output is correct
75 Correct 4 ms 6488 KB Output is correct
76 Correct 4 ms 6492 KB Output is correct
77 Correct 4 ms 6508 KB Output is correct
78 Correct 4 ms 6456 KB Output is correct
79 Correct 5 ms 6488 KB Output is correct
80 Correct 50 ms 13740 KB Output is correct
81 Correct 53 ms 14108 KB Output is correct
82 Correct 47 ms 13672 KB Output is correct
83 Correct 47 ms 13520 KB Output is correct
84 Correct 4 ms 6236 KB Output is correct
85 Correct 5 ms 6236 KB Output is correct
86 Correct 4 ms 6236 KB Output is correct
87 Correct 4 ms 6460 KB Output is correct
88 Correct 4 ms 6436 KB Output is correct
89 Correct 4 ms 6236 KB Output is correct
90 Correct 5 ms 6236 KB Output is correct
91 Correct 4 ms 6492 KB Output is correct
92 Correct 4 ms 6236 KB Output is correct
93 Correct 4 ms 6236 KB Output is correct
94 Correct 3 ms 6236 KB Output is correct
95 Correct 3 ms 6236 KB Output is correct
96 Correct 3 ms 6232 KB Output is correct
97 Correct 3 ms 6236 KB Output is correct
98 Correct 3 ms 6236 KB Output is correct
99 Correct 3 ms 6236 KB Output is correct
100 Correct 3 ms 6236 KB Output is correct
101 Correct 3 ms 6236 KB Output is correct
102 Correct 3 ms 6236 KB Output is correct
103 Correct 3 ms 6236 KB Output is correct
104 Correct 7 ms 7080 KB Output is correct
105 Correct 12 ms 8660 KB Output is correct
106 Correct 3 ms 6232 KB Output is correct
107 Correct 21 ms 10300 KB Output is correct
108 Correct 26 ms 11604 KB Output is correct
109 Correct 3 ms 6236 KB Output is correct
110 Correct 43 ms 13416 KB Output is correct
111 Correct 46 ms 15048 KB Output is correct
112 Correct 4 ms 6232 KB Output is correct
113 Correct 61 ms 17864 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1035 ms 9360 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 6236 KB Output is correct
2 Correct 3 ms 6180 KB Output is correct
3 Correct 3 ms 6236 KB Output is correct
4 Correct 3 ms 6232 KB Output is correct
5 Correct 3 ms 6124 KB Output is correct
6 Correct 3 ms 6232 KB Output is correct
7 Correct 3 ms 6236 KB Output is correct
8 Correct 3 ms 6236 KB Output is correct
9 Correct 3 ms 6236 KB Output is correct
10 Correct 3 ms 6236 KB Output is correct
11 Correct 3 ms 6236 KB Output is correct
12 Correct 3 ms 6236 KB Output is correct
13 Correct 3 ms 6236 KB Output is correct
14 Correct 3 ms 6236 KB Output is correct
15 Correct 3 ms 6236 KB Output is correct
16 Correct 3 ms 6236 KB Output is correct
17 Correct 4 ms 6260 KB Output is correct
18 Correct 3 ms 6236 KB Output is correct
19 Correct 3 ms 6236 KB Output is correct
20 Correct 3 ms 6236 KB Output is correct
21 Correct 3 ms 6236 KB Output is correct
22 Correct 3 ms 6236 KB Output is correct
23 Correct 3 ms 6236 KB Output is correct
24 Correct 3 ms 6236 KB Output is correct
25 Correct 3 ms 6236 KB Output is correct
26 Correct 46 ms 6968 KB Output is correct
27 Correct 86 ms 7016 KB Output is correct
28 Correct 233 ms 6408 KB Output is correct
29 Correct 81 ms 6620 KB Output is correct
30 Correct 119 ms 6628 KB Output is correct
31 Correct 193 ms 6740 KB Output is correct
32 Correct 73 ms 6308 KB Output is correct
33 Correct 109 ms 6552 KB Output is correct
34 Correct 180 ms 6588 KB Output is correct
35 Correct 4 ms 6488 KB Output is correct
36 Correct 3 ms 6236 KB Output is correct
37 Correct 3 ms 6236 KB Output is correct
38 Correct 3 ms 6236 KB Output is correct
39 Correct 3 ms 6236 KB Output is correct
40 Correct 26 ms 6236 KB Output is correct
41 Correct 32 ms 6456 KB Output is correct
42 Correct 3 ms 6220 KB Output is correct
43 Correct 3 ms 6236 KB Output is correct
44 Correct 3 ms 6236 KB Output is correct
45 Correct 3 ms 6236 KB Output is correct
46 Correct 4 ms 6236 KB Output is correct
47 Correct 3 ms 6232 KB Output is correct
48 Correct 3 ms 6232 KB Output is correct
49 Correct 3 ms 6232 KB Output is correct
50 Correct 3 ms 6236 KB Output is correct
51 Correct 3 ms 6236 KB Output is correct
52 Correct 2 ms 6236 KB Output is correct
53 Correct 3 ms 6236 KB Output is correct
54 Correct 4 ms 6652 KB Output is correct
55 Correct 3 ms 6488 KB Output is correct
56 Correct 320 ms 7016 KB Output is correct
57 Correct 596 ms 7068 KB Output is correct
58 Correct 4 ms 6460 KB Output is correct
59 Correct 4 ms 6492 KB Output is correct
60 Correct 418 ms 6972 KB Output is correct
61 Correct 526 ms 6968 KB Output is correct
62 Correct 5 ms 6492 KB Output is correct
63 Correct 4 ms 6460 KB Output is correct
64 Correct 713 ms 6544 KB Output is correct
65 Correct 313 ms 7028 KB Output is correct
66 Correct 4 ms 6492 KB Output is correct
67 Correct 4 ms 6460 KB Output is correct
68 Correct 257 ms 6380 KB Output is correct
69 Correct 239 ms 6400 KB Output is correct
70 Correct 486 ms 6972 KB Output is correct
71 Correct 486 ms 6340 KB Output is correct
72 Correct 4 ms 6492 KB Output is correct
73 Correct 4 ms 6492 KB Output is correct
74 Correct 75 ms 6436 KB Output is correct
75 Correct 91 ms 6580 KB Output is correct
76 Correct 4 ms 6492 KB Output is correct
77 Correct 5 ms 6492 KB Output is correct
78 Correct 500 ms 6344 KB Output is correct
79 Correct 491 ms 6972 KB Output is correct
80 Correct 692 ms 6316 KB Output is correct
81 Correct 722 ms 6276 KB Output is correct
82 Correct 101 ms 6428 KB Output is correct
83 Correct 90 ms 7220 KB Output is correct
84 Correct 648 ms 6600 KB Output is correct
85 Correct 735 ms 6968 KB Output is correct
86 Correct 616 ms 6684 KB Output is correct
87 Correct 149 ms 6768 KB Output is correct
88 Correct 304 ms 6380 KB Output is correct
89 Correct 328 ms 7012 KB Output is correct
90 Correct 452 ms 7076 KB Output is correct
91 Correct 532 ms 6968 KB Output is correct
92 Correct 3 ms 6456 KB Output is correct
93 Correct 4 ms 6232 KB Output is correct
94 Correct 4 ms 6224 KB Output is correct
95 Correct 4 ms 6444 KB Output is correct
96 Correct 4 ms 6236 KB Output is correct
97 Correct 4 ms 6236 KB Output is correct
98 Correct 4 ms 6264 KB Output is correct
99 Correct 4 ms 6492 KB Output is correct
100 Correct 4 ms 6460 KB Output is correct
101 Correct 4 ms 6236 KB Output is correct
102 Correct 3 ms 6232 KB Output is correct
103 Correct 3 ms 6220 KB Output is correct
104 Correct 3 ms 6236 KB Output is correct
105 Correct 3 ms 6236 KB Output is correct
106 Correct 3 ms 6236 KB Output is correct
107 Correct 3 ms 6236 KB Output is correct
108 Correct 3 ms 6236 KB Output is correct
109 Correct 3 ms 6232 KB Output is correct
110 Correct 3 ms 6236 KB Output is correct
111 Correct 3 ms 6248 KB Output is correct
112 Correct 3 ms 6236 KB Output is correct
113 Correct 3 ms 6236 KB Output is correct
114 Correct 3 ms 6236 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 37 ms 16872 KB Output is correct
2 Correct 48 ms 16584 KB Output is correct
3 Correct 26 ms 13116 KB Output is correct
4 Correct 10 ms 7768 KB Output is correct
5 Correct 7 ms 7260 KB Output is correct
6 Correct 12 ms 8676 KB Output is correct
7 Correct 3 ms 6236 KB Output is correct
8 Correct 20 ms 10216 KB Output is correct
9 Correct 25 ms 11668 KB Output is correct
10 Correct 3 ms 6236 KB Output is correct
11 Correct 38 ms 13296 KB Output is correct
12 Correct 45 ms 15112 KB Output is correct
13 Correct 3 ms 6232 KB Output is correct
14 Correct 4 ms 6236 KB Output is correct
15 Correct 3 ms 6180 KB Output is correct
16 Correct 3 ms 6236 KB Output is correct
17 Correct 3 ms 6232 KB Output is correct
18 Correct 3 ms 6124 KB Output is correct
19 Correct 3 ms 6232 KB Output is correct
20 Correct 3 ms 6236 KB Output is correct
21 Correct 3 ms 6236 KB Output is correct
22 Correct 3 ms 6236 KB Output is correct
23 Correct 3 ms 6236 KB Output is correct
24 Correct 3 ms 6236 KB Output is correct
25 Correct 3 ms 6236 KB Output is correct
26 Correct 3 ms 6236 KB Output is correct
27 Correct 3 ms 6236 KB Output is correct
28 Correct 3 ms 6236 KB Output is correct
29 Correct 3 ms 6236 KB Output is correct
30 Correct 4 ms 6260 KB Output is correct
31 Correct 3 ms 6236 KB Output is correct
32 Correct 3 ms 6236 KB Output is correct
33 Correct 3 ms 6236 KB Output is correct
34 Correct 3 ms 6236 KB Output is correct
35 Correct 3 ms 6236 KB Output is correct
36 Correct 3 ms 6236 KB Output is correct
37 Correct 3 ms 6236 KB Output is correct
38 Correct 3 ms 6236 KB Output is correct
39 Correct 36 ms 16516 KB Output is correct
40 Correct 38 ms 16636 KB Output is correct
41 Correct 33 ms 13264 KB Output is correct
42 Correct 8 ms 7768 KB Output is correct
43 Correct 3 ms 6236 KB Output is correct
44 Correct 3 ms 6236 KB Output is correct
45 Correct 3 ms 6236 KB Output is correct
46 Correct 3 ms 6236 KB Output is correct
47 Correct 3 ms 6224 KB Output is correct
48 Correct 3 ms 6236 KB Output is correct
49 Correct 3 ms 6236 KB Output is correct
50 Correct 3 ms 6236 KB Output is correct
51 Correct 3 ms 6236 KB Output is correct
52 Correct 3 ms 6232 KB Output is correct
53 Correct 3 ms 6232 KB Output is correct
54 Correct 3 ms 6236 KB Output is correct
55 Correct 3 ms 6236 KB Output is correct
56 Correct 3 ms 6232 KB Output is correct
57 Correct 51 ms 14176 KB Output is correct
58 Correct 50 ms 13872 KB Output is correct
59 Correct 57 ms 13776 KB Output is correct
60 Correct 49 ms 13496 KB Output is correct
61 Correct 58 ms 13792 KB Output is correct
62 Correct 45 ms 13352 KB Output is correct
63 Correct 47 ms 13444 KB Output is correct
64 Correct 44 ms 13512 KB Output is correct
65 Correct 46 ms 13760 KB Output is correct
66 Correct 48 ms 13764 KB Output is correct
67 Correct 51 ms 14028 KB Output is correct
68 Correct 50 ms 13556 KB Output is correct
69 Correct 54 ms 13744 KB Output is correct
70 Correct 55 ms 14032 KB Output is correct
71 Correct 3 ms 6232 KB Output is correct
72 Correct 4 ms 6492 KB Output is correct
73 Correct 4 ms 6492 KB Output is correct
74 Correct 4 ms 6492 KB Output is correct
75 Correct 4 ms 6488 KB Output is correct
76 Correct 4 ms 6492 KB Output is correct
77 Correct 4 ms 6508 KB Output is correct
78 Correct 4 ms 6456 KB Output is correct
79 Correct 5 ms 6488 KB Output is correct
80 Correct 50 ms 13740 KB Output is correct
81 Correct 53 ms 14108 KB Output is correct
82 Correct 47 ms 13672 KB Output is correct
83 Correct 47 ms 13520 KB Output is correct
84 Correct 4 ms 6236 KB Output is correct
85 Correct 5 ms 6236 KB Output is correct
86 Correct 4 ms 6236 KB Output is correct
87 Correct 4 ms 6460 KB Output is correct
88 Correct 4 ms 6436 KB Output is correct
89 Correct 4 ms 6236 KB Output is correct
90 Correct 5 ms 6236 KB Output is correct
91 Correct 4 ms 6492 KB Output is correct
92 Correct 4 ms 6236 KB Output is correct
93 Correct 4 ms 6236 KB Output is correct
94 Correct 3 ms 6236 KB Output is correct
95 Correct 3 ms 6236 KB Output is correct
96 Correct 3 ms 6232 KB Output is correct
97 Correct 3 ms 6236 KB Output is correct
98 Correct 3 ms 6236 KB Output is correct
99 Correct 3 ms 6236 KB Output is correct
100 Correct 3 ms 6236 KB Output is correct
101 Correct 3 ms 6236 KB Output is correct
102 Correct 3 ms 6236 KB Output is correct
103 Correct 3 ms 6236 KB Output is correct
104 Correct 7 ms 7080 KB Output is correct
105 Correct 12 ms 8660 KB Output is correct
106 Correct 3 ms 6232 KB Output is correct
107 Correct 21 ms 10300 KB Output is correct
108 Correct 26 ms 11604 KB Output is correct
109 Correct 3 ms 6236 KB Output is correct
110 Correct 43 ms 13416 KB Output is correct
111 Correct 46 ms 15048 KB Output is correct
112 Correct 4 ms 6232 KB Output is correct
113 Correct 61 ms 17864 KB Output is correct
114 Execution timed out 1035 ms 9360 KB Time limit exceeded
115 Halted 0 ms 0 KB -