답안 #932406

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
932406 2024-02-23T09:43:54 Z pan 꿈 (IOI13_dreaming) C++17
59 / 100
1000 ms 19492 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> dummy1(100005, INF);
vector<ll> dummy2(100005, 0);
vector<ll> dist, 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 = dummy2;
	dist = dummy1;
}
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 50 ms 18372 KB Output is correct
2 Correct 45 ms 18116 KB Output is correct
3 Correct 26 ms 14804 KB Output is correct
4 Correct 8 ms 10076 KB Output is correct
5 Correct 7 ms 9564 KB Output is correct
6 Correct 12 ms 10968 KB Output is correct
7 Correct 4 ms 8540 KB Output is correct
8 Correct 21 ms 12432 KB Output is correct
9 Correct 29 ms 13600 KB Output is correct
10 Correct 4 ms 8680 KB Output is correct
11 Correct 46 ms 14968 KB Output is correct
12 Correct 72 ms 16716 KB Output is correct
13 Correct 4 ms 8540 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 8540 KB Output is correct
2 Correct 4 ms 8540 KB Output is correct
3 Correct 3 ms 8540 KB Output is correct
4 Correct 4 ms 8540 KB Output is correct
5 Correct 4 ms 8540 KB Output is correct
6 Correct 4 ms 8540 KB Output is correct
7 Correct 4 ms 8536 KB Output is correct
8 Correct 4 ms 8540 KB Output is correct
9 Correct 3 ms 8540 KB Output is correct
10 Correct 4 ms 8540 KB Output is correct
11 Correct 4 ms 8540 KB Output is correct
12 Correct 4 ms 8536 KB Output is correct
13 Correct 4 ms 8540 KB Output is correct
14 Correct 4 ms 8528 KB Output is correct
15 Correct 4 ms 8540 KB Output is correct
16 Correct 4 ms 8540 KB Output is correct
17 Correct 5 ms 8592 KB Output is correct
18 Correct 4 ms 8540 KB Output is correct
19 Correct 4 ms 8540 KB Output is correct
20 Correct 4 ms 8540 KB Output is correct
21 Correct 4 ms 8540 KB Output is correct
22 Correct 4 ms 8540 KB Output is correct
23 Correct 4 ms 8540 KB Output is correct
24 Correct 4 ms 8540 KB Output is correct
25 Correct 4 ms 8540 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 50 ms 18372 KB Output is correct
2 Correct 45 ms 18116 KB Output is correct
3 Correct 26 ms 14804 KB Output is correct
4 Correct 8 ms 10076 KB Output is correct
5 Correct 7 ms 9564 KB Output is correct
6 Correct 12 ms 10968 KB Output is correct
7 Correct 4 ms 8540 KB Output is correct
8 Correct 21 ms 12432 KB Output is correct
9 Correct 29 ms 13600 KB Output is correct
10 Correct 4 ms 8680 KB Output is correct
11 Correct 46 ms 14968 KB Output is correct
12 Correct 72 ms 16716 KB Output is correct
13 Correct 4 ms 8540 KB Output is correct
14 Correct 4 ms 8540 KB Output is correct
15 Correct 4 ms 8540 KB Output is correct
16 Correct 3 ms 8540 KB Output is correct
17 Correct 4 ms 8540 KB Output is correct
18 Correct 4 ms 8540 KB Output is correct
19 Correct 4 ms 8540 KB Output is correct
20 Correct 4 ms 8536 KB Output is correct
21 Correct 4 ms 8540 KB Output is correct
22 Correct 3 ms 8540 KB Output is correct
23 Correct 4 ms 8540 KB Output is correct
24 Correct 4 ms 8540 KB Output is correct
25 Correct 4 ms 8536 KB Output is correct
26 Correct 4 ms 8540 KB Output is correct
27 Correct 4 ms 8528 KB Output is correct
28 Correct 4 ms 8540 KB Output is correct
29 Correct 4 ms 8540 KB Output is correct
30 Correct 5 ms 8592 KB Output is correct
31 Correct 4 ms 8540 KB Output is correct
32 Correct 4 ms 8540 KB Output is correct
33 Correct 4 ms 8540 KB Output is correct
34 Correct 4 ms 8540 KB Output is correct
35 Correct 4 ms 8540 KB Output is correct
36 Correct 4 ms 8540 KB Output is correct
37 Correct 4 ms 8540 KB Output is correct
38 Correct 4 ms 8540 KB Output is correct
39 Correct 37 ms 18128 KB Output is correct
40 Correct 38 ms 18368 KB Output is correct
41 Correct 26 ms 14800 KB Output is correct
42 Correct 9 ms 10328 KB Output is correct
43 Correct 4 ms 8540 KB Output is correct
44 Correct 4 ms 8540 KB Output is correct
45 Correct 4 ms 8540 KB Output is correct
46 Correct 3 ms 8540 KB Output is correct
47 Correct 3 ms 8540 KB Output is correct
48 Correct 4 ms 8540 KB Output is correct
49 Correct 4 ms 8548 KB Output is correct
50 Correct 4 ms 8540 KB Output is correct
51 Correct 4 ms 8536 KB Output is correct
52 Correct 4 ms 8596 KB Output is correct
53 Correct 4 ms 8540 KB Output is correct
54 Correct 4 ms 8540 KB Output is correct
55 Correct 4 ms 8540 KB Output is correct
56 Correct 4 ms 8588 KB Output is correct
57 Correct 50 ms 15308 KB Output is correct
58 Correct 63 ms 14972 KB Output is correct
59 Correct 47 ms 15052 KB Output is correct
60 Correct 56 ms 14684 KB Output is correct
61 Correct 47 ms 14792 KB Output is correct
62 Correct 51 ms 14536 KB Output is correct
63 Correct 42 ms 14796 KB Output is correct
64 Correct 43 ms 14796 KB Output is correct
65 Correct 48 ms 14824 KB Output is correct
66 Correct 60 ms 15044 KB Output is correct
67 Correct 80 ms 15040 KB Output is correct
68 Correct 54 ms 14972 KB Output is correct
69 Correct 51 ms 14804 KB Output is correct
70 Correct 49 ms 14800 KB Output is correct
71 Correct 4 ms 8540 KB Output is correct
72 Correct 5 ms 8784 KB Output is correct
73 Correct 5 ms 8796 KB Output is correct
74 Correct 5 ms 8796 KB Output is correct
75 Correct 4 ms 8792 KB Output is correct
76 Correct 5 ms 8836 KB Output is correct
77 Correct 5 ms 8796 KB Output is correct
78 Correct 5 ms 8792 KB Output is correct
79 Correct 5 ms 8796 KB Output is correct
80 Correct 56 ms 14844 KB Output is correct
81 Correct 54 ms 14796 KB Output is correct
82 Correct 46 ms 14968 KB Output is correct
83 Correct 56 ms 15368 KB Output is correct
84 Correct 5 ms 8760 KB Output is correct
85 Correct 4 ms 8540 KB Output is correct
86 Correct 4 ms 8764 KB Output is correct
87 Correct 4 ms 8764 KB Output is correct
88 Correct 4 ms 8764 KB Output is correct
89 Correct 5 ms 8704 KB Output is correct
90 Correct 4 ms 8764 KB Output is correct
91 Correct 5 ms 8796 KB Output is correct
92 Correct 6 ms 8756 KB Output is correct
93 Correct 4 ms 8764 KB Output is correct
94 Correct 4 ms 8540 KB Output is correct
95 Correct 6 ms 8540 KB Output is correct
96 Correct 4 ms 8592 KB Output is correct
97 Correct 4 ms 8540 KB Output is correct
98 Correct 4 ms 8540 KB Output is correct
99 Correct 4 ms 8604 KB Output is correct
100 Correct 4 ms 8540 KB Output is correct
101 Correct 4 ms 8540 KB Output is correct
102 Correct 4 ms 8540 KB Output is correct
103 Correct 4 ms 8540 KB Output is correct
104 Correct 8 ms 9444 KB Output is correct
105 Correct 13 ms 10968 KB Output is correct
106 Correct 4 ms 8540 KB Output is correct
107 Correct 22 ms 12244 KB Output is correct
108 Correct 30 ms 13528 KB Output is correct
109 Correct 4 ms 8540 KB Output is correct
110 Correct 37 ms 15052 KB Output is correct
111 Correct 44 ms 16680 KB Output is correct
112 Correct 4 ms 8540 KB Output is correct
113 Correct 65 ms 19492 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1054 ms 10972 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 8540 KB Output is correct
2 Correct 4 ms 8540 KB Output is correct
3 Correct 3 ms 8540 KB Output is correct
4 Correct 4 ms 8540 KB Output is correct
5 Correct 4 ms 8540 KB Output is correct
6 Correct 4 ms 8540 KB Output is correct
7 Correct 4 ms 8536 KB Output is correct
8 Correct 4 ms 8540 KB Output is correct
9 Correct 3 ms 8540 KB Output is correct
10 Correct 4 ms 8540 KB Output is correct
11 Correct 4 ms 8540 KB Output is correct
12 Correct 4 ms 8536 KB Output is correct
13 Correct 4 ms 8540 KB Output is correct
14 Correct 4 ms 8528 KB Output is correct
15 Correct 4 ms 8540 KB Output is correct
16 Correct 4 ms 8540 KB Output is correct
17 Correct 5 ms 8592 KB Output is correct
18 Correct 4 ms 8540 KB Output is correct
19 Correct 4 ms 8540 KB Output is correct
20 Correct 4 ms 8540 KB Output is correct
21 Correct 4 ms 8540 KB Output is correct
22 Correct 4 ms 8540 KB Output is correct
23 Correct 4 ms 8540 KB Output is correct
24 Correct 4 ms 8540 KB Output is correct
25 Correct 4 ms 8540 KB Output is correct
26 Correct 33 ms 9276 KB Output is correct
27 Correct 64 ms 9316 KB Output is correct
28 Correct 191 ms 9204 KB Output is correct
29 Correct 77 ms 8884 KB Output is correct
30 Correct 102 ms 8928 KB Output is correct
31 Correct 165 ms 9100 KB Output is correct
32 Correct 70 ms 8920 KB Output is correct
33 Correct 98 ms 8888 KB Output is correct
34 Correct 159 ms 9092 KB Output is correct
35 Correct 5 ms 8540 KB Output is correct
36 Correct 4 ms 8540 KB Output is correct
37 Correct 3 ms 8540 KB Output is correct
38 Correct 3 ms 8540 KB Output is correct
39 Correct 4 ms 8536 KB Output is correct
40 Correct 22 ms 8540 KB Output is correct
41 Correct 16 ms 8540 KB Output is correct
42 Correct 4 ms 8540 KB Output is correct
43 Correct 3 ms 8540 KB Output is correct
44 Correct 4 ms 8540 KB Output is correct
45 Correct 3 ms 8540 KB Output is correct
46 Correct 4 ms 8536 KB Output is correct
47 Correct 4 ms 8540 KB Output is correct
48 Correct 4 ms 8540 KB Output is correct
49 Correct 4 ms 8600 KB Output is correct
50 Correct 4 ms 8540 KB Output is correct
51 Correct 4 ms 8540 KB Output is correct
52 Correct 3 ms 8536 KB Output is correct
53 Correct 4 ms 8540 KB Output is correct
54 Correct 4 ms 8796 KB Output is correct
55 Correct 4 ms 8796 KB Output is correct
56 Correct 239 ms 9320 KB Output is correct
57 Correct 423 ms 9400 KB Output is correct
58 Correct 5 ms 8796 KB Output is correct
59 Correct 5 ms 8796 KB Output is correct
60 Correct 309 ms 9276 KB Output is correct
61 Correct 385 ms 9420 KB Output is correct
62 Correct 5 ms 8796 KB Output is correct
63 Correct 5 ms 8792 KB Output is correct
64 Correct 489 ms 9008 KB Output is correct
65 Correct 215 ms 9332 KB Output is correct
66 Correct 6 ms 8796 KB Output is correct
67 Correct 5 ms 8796 KB Output is correct
68 Correct 185 ms 8712 KB Output is correct
69 Correct 182 ms 8920 KB Output is correct
70 Correct 355 ms 9272 KB Output is correct
71 Correct 364 ms 8920 KB Output is correct
72 Correct 5 ms 8796 KB Output is correct
73 Correct 5 ms 8796 KB Output is correct
74 Correct 62 ms 8908 KB Output is correct
75 Correct 76 ms 8928 KB Output is correct
76 Correct 5 ms 8792 KB Output is correct
77 Correct 5 ms 8796 KB Output is correct
78 Correct 356 ms 8672 KB Output is correct
79 Correct 372 ms 9420 KB Output is correct
80 Correct 466 ms 8536 KB Output is correct
81 Correct 523 ms 8868 KB Output is correct
82 Correct 80 ms 8836 KB Output is correct
83 Correct 65 ms 9552 KB Output is correct
84 Correct 534 ms 8928 KB Output is correct
85 Correct 482 ms 9376 KB Output is correct
86 Correct 550 ms 9112 KB Output is correct
87 Correct 140 ms 9068 KB Output is correct
88 Correct 209 ms 8708 KB Output is correct
89 Correct 233 ms 9320 KB Output is correct
90 Correct 325 ms 9620 KB Output is correct
91 Correct 345 ms 9276 KB Output is correct
92 Correct 4 ms 8760 KB Output is correct
93 Correct 4 ms 8540 KB Output is correct
94 Correct 4 ms 8764 KB Output is correct
95 Correct 4 ms 8764 KB Output is correct
96 Correct 5 ms 8760 KB Output is correct
97 Correct 5 ms 8764 KB Output is correct
98 Correct 5 ms 8764 KB Output is correct
99 Correct 5 ms 8796 KB Output is correct
100 Correct 4 ms 8764 KB Output is correct
101 Correct 4 ms 8764 KB Output is correct
102 Correct 3 ms 8540 KB Output is correct
103 Correct 4 ms 8540 KB Output is correct
104 Correct 4 ms 8600 KB Output is correct
105 Correct 4 ms 8540 KB Output is correct
106 Correct 4 ms 8540 KB Output is correct
107 Correct 4 ms 8540 KB Output is correct
108 Correct 4 ms 8440 KB Output is correct
109 Correct 4 ms 8540 KB Output is correct
110 Correct 4 ms 8540 KB Output is correct
111 Correct 4 ms 8540 KB Output is correct
112 Correct 5 ms 8540 KB Output is correct
113 Correct 4 ms 8540 KB Output is correct
114 Correct 4 ms 8540 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 50 ms 18372 KB Output is correct
2 Correct 45 ms 18116 KB Output is correct
3 Correct 26 ms 14804 KB Output is correct
4 Correct 8 ms 10076 KB Output is correct
5 Correct 7 ms 9564 KB Output is correct
6 Correct 12 ms 10968 KB Output is correct
7 Correct 4 ms 8540 KB Output is correct
8 Correct 21 ms 12432 KB Output is correct
9 Correct 29 ms 13600 KB Output is correct
10 Correct 4 ms 8680 KB Output is correct
11 Correct 46 ms 14968 KB Output is correct
12 Correct 72 ms 16716 KB Output is correct
13 Correct 4 ms 8540 KB Output is correct
14 Correct 4 ms 8540 KB Output is correct
15 Correct 4 ms 8540 KB Output is correct
16 Correct 3 ms 8540 KB Output is correct
17 Correct 4 ms 8540 KB Output is correct
18 Correct 4 ms 8540 KB Output is correct
19 Correct 4 ms 8540 KB Output is correct
20 Correct 4 ms 8536 KB Output is correct
21 Correct 4 ms 8540 KB Output is correct
22 Correct 3 ms 8540 KB Output is correct
23 Correct 4 ms 8540 KB Output is correct
24 Correct 4 ms 8540 KB Output is correct
25 Correct 4 ms 8536 KB Output is correct
26 Correct 4 ms 8540 KB Output is correct
27 Correct 4 ms 8528 KB Output is correct
28 Correct 4 ms 8540 KB Output is correct
29 Correct 4 ms 8540 KB Output is correct
30 Correct 5 ms 8592 KB Output is correct
31 Correct 4 ms 8540 KB Output is correct
32 Correct 4 ms 8540 KB Output is correct
33 Correct 4 ms 8540 KB Output is correct
34 Correct 4 ms 8540 KB Output is correct
35 Correct 4 ms 8540 KB Output is correct
36 Correct 4 ms 8540 KB Output is correct
37 Correct 4 ms 8540 KB Output is correct
38 Correct 4 ms 8540 KB Output is correct
39 Correct 37 ms 18128 KB Output is correct
40 Correct 38 ms 18368 KB Output is correct
41 Correct 26 ms 14800 KB Output is correct
42 Correct 9 ms 10328 KB Output is correct
43 Correct 4 ms 8540 KB Output is correct
44 Correct 4 ms 8540 KB Output is correct
45 Correct 4 ms 8540 KB Output is correct
46 Correct 3 ms 8540 KB Output is correct
47 Correct 3 ms 8540 KB Output is correct
48 Correct 4 ms 8540 KB Output is correct
49 Correct 4 ms 8548 KB Output is correct
50 Correct 4 ms 8540 KB Output is correct
51 Correct 4 ms 8536 KB Output is correct
52 Correct 4 ms 8596 KB Output is correct
53 Correct 4 ms 8540 KB Output is correct
54 Correct 4 ms 8540 KB Output is correct
55 Correct 4 ms 8540 KB Output is correct
56 Correct 4 ms 8588 KB Output is correct
57 Correct 50 ms 15308 KB Output is correct
58 Correct 63 ms 14972 KB Output is correct
59 Correct 47 ms 15052 KB Output is correct
60 Correct 56 ms 14684 KB Output is correct
61 Correct 47 ms 14792 KB Output is correct
62 Correct 51 ms 14536 KB Output is correct
63 Correct 42 ms 14796 KB Output is correct
64 Correct 43 ms 14796 KB Output is correct
65 Correct 48 ms 14824 KB Output is correct
66 Correct 60 ms 15044 KB Output is correct
67 Correct 80 ms 15040 KB Output is correct
68 Correct 54 ms 14972 KB Output is correct
69 Correct 51 ms 14804 KB Output is correct
70 Correct 49 ms 14800 KB Output is correct
71 Correct 4 ms 8540 KB Output is correct
72 Correct 5 ms 8784 KB Output is correct
73 Correct 5 ms 8796 KB Output is correct
74 Correct 5 ms 8796 KB Output is correct
75 Correct 4 ms 8792 KB Output is correct
76 Correct 5 ms 8836 KB Output is correct
77 Correct 5 ms 8796 KB Output is correct
78 Correct 5 ms 8792 KB Output is correct
79 Correct 5 ms 8796 KB Output is correct
80 Correct 56 ms 14844 KB Output is correct
81 Correct 54 ms 14796 KB Output is correct
82 Correct 46 ms 14968 KB Output is correct
83 Correct 56 ms 15368 KB Output is correct
84 Correct 5 ms 8760 KB Output is correct
85 Correct 4 ms 8540 KB Output is correct
86 Correct 4 ms 8764 KB Output is correct
87 Correct 4 ms 8764 KB Output is correct
88 Correct 4 ms 8764 KB Output is correct
89 Correct 5 ms 8704 KB Output is correct
90 Correct 4 ms 8764 KB Output is correct
91 Correct 5 ms 8796 KB Output is correct
92 Correct 6 ms 8756 KB Output is correct
93 Correct 4 ms 8764 KB Output is correct
94 Correct 4 ms 8540 KB Output is correct
95 Correct 6 ms 8540 KB Output is correct
96 Correct 4 ms 8592 KB Output is correct
97 Correct 4 ms 8540 KB Output is correct
98 Correct 4 ms 8540 KB Output is correct
99 Correct 4 ms 8604 KB Output is correct
100 Correct 4 ms 8540 KB Output is correct
101 Correct 4 ms 8540 KB Output is correct
102 Correct 4 ms 8540 KB Output is correct
103 Correct 4 ms 8540 KB Output is correct
104 Correct 8 ms 9444 KB Output is correct
105 Correct 13 ms 10968 KB Output is correct
106 Correct 4 ms 8540 KB Output is correct
107 Correct 22 ms 12244 KB Output is correct
108 Correct 30 ms 13528 KB Output is correct
109 Correct 4 ms 8540 KB Output is correct
110 Correct 37 ms 15052 KB Output is correct
111 Correct 44 ms 16680 KB Output is correct
112 Correct 4 ms 8540 KB Output is correct
113 Correct 65 ms 19492 KB Output is correct
114 Execution timed out 1054 ms 10972 KB Time limit exceeded
115 Halted 0 ms 0 KB -