Submission #972431

# Submission time Handle Problem Language Result Execution time Memory
972431 2024-04-30T12:05:17 Z Nika533 Dreaming (IOI13_dreaming) C++14
47 / 100
48 ms 16432 KB
#pragma GCC diagnostic warning "-std=c++11"
#include <bits/stdc++.h>
#include "dreaming.h"
#define pb push_back
#define f first
#define s second
#define MOD 1000000007
#define flush fflush(stdout)
#define all(x) (x).begin(),(x).end()
#define allr(x) (x).rbegin(), (x).rend()
#define pii pair<int,int>

using namespace std;

const int NMAX=1e5+5;
int n,m,fix[NMAX],mx[NMAX],NEXT[NMAX];
vector<pii> g[NMAX];

void dfs(int x, int p) {
	mx[x]=0; NEXT[x]=-1; fix[x]=1;
	if (x!=p && g[x].size()==1) return;
	for (auto A:g[x]) {
		int y=A.f,w=A.s;
		if (y==p) continue;
		dfs(y,x);
		if (mx[x]<w+mx[y]) {
			mx[x]=w+mx[y];
			NEXT[x]=y;
		}
	}
}

int travelTime(int N, int M, int L, int A[], int B[], int T[]) {
	n=N; m=M;
	for (int i=0; i<m; i++) {
		int a=A[i],b=B[i],c=T[i];
		g[a].pb({b,c}); g[b].pb({a,c});
	}
	
	//subtask 1 & 2 & 3
	
	int ans=0;
	vector<int> u;
	
	for (int i=0; i<n; i++) {
		if (fix[i]==0) {
			
			vector<int> v;
			
			dfs(i,i);
			int j=i;
			while (j>=0) {
				v.pb(j); j=NEXT[j]; 
			}
			
			int st=v.back(); v.clear();
			
			dfs(st,st);
			j=st;
			while (j>=0) {
				v.pb(j); j=NEXT[j];
			}
			
			int d=mx[st],mn=1e9;
			for (auto x:v) {
				mn=min(mn,max(mx[x],d-mx[x]));
			}
			u.pb(mn);
			ans=max(ans,mx[st]);
		}
	}
	sort(all(u)); reverse(all(u));
	if (u.size()==1) return ans;
	ans=max(ans,u[0]+L+u[1]);
	return ans;
}

Compilation message

dreaming.cpp:1:32: warning: '-std=c++11' is not an option that controls warnings [-Wpragmas]
    1 | #pragma GCC diagnostic warning "-std=c++11"
      |                                ^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 34 ms 15572 KB Output is correct
2 Correct 33 ms 15832 KB Output is correct
3 Correct 25 ms 11984 KB Output is correct
4 Correct 6 ms 6236 KB Output is correct
5 Correct 5 ms 5212 KB Output is correct
6 Correct 9 ms 7112 KB Output is correct
7 Correct 1 ms 4444 KB Output is correct
8 Correct 16 ms 8268 KB Output is correct
9 Correct 21 ms 9884 KB Output is correct
10 Correct 1 ms 4444 KB Output is correct
11 Correct 29 ms 11072 KB Output is correct
12 Correct 34 ms 13352 KB Output is correct
13 Correct 1 ms 4444 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4444 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 1 ms 4552 KB Output is correct
4 Correct 1 ms 4444 KB Output is correct
5 Correct 1 ms 4540 KB Output is correct
6 Correct 1 ms 4444 KB Output is correct
7 Correct 1 ms 4444 KB Output is correct
8 Correct 1 ms 4444 KB Output is correct
9 Correct 1 ms 4444 KB Output is correct
10 Correct 1 ms 4444 KB Output is correct
11 Correct 1 ms 4444 KB Output is correct
12 Correct 1 ms 4444 KB Output is correct
13 Correct 1 ms 4444 KB Output is correct
14 Correct 1 ms 4444 KB Output is correct
15 Correct 1 ms 4444 KB Output is correct
16 Correct 1 ms 4444 KB Output is correct
17 Correct 1 ms 4444 KB Output is correct
18 Correct 1 ms 4444 KB Output is correct
19 Correct 1 ms 4444 KB Output is correct
20 Correct 1 ms 4532 KB Output is correct
21 Correct 1 ms 4440 KB Output is correct
22 Correct 1 ms 4444 KB Output is correct
23 Correct 1 ms 4444 KB Output is correct
24 Correct 1 ms 4444 KB Output is correct
25 Correct 1 ms 4444 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 34 ms 15572 KB Output is correct
2 Correct 33 ms 15832 KB Output is correct
3 Correct 25 ms 11984 KB Output is correct
4 Correct 6 ms 6236 KB Output is correct
5 Correct 5 ms 5212 KB Output is correct
6 Correct 9 ms 7112 KB Output is correct
7 Correct 1 ms 4444 KB Output is correct
8 Correct 16 ms 8268 KB Output is correct
9 Correct 21 ms 9884 KB Output is correct
10 Correct 1 ms 4444 KB Output is correct
11 Correct 29 ms 11072 KB Output is correct
12 Correct 34 ms 13352 KB Output is correct
13 Correct 1 ms 4444 KB Output is correct
14 Correct 2 ms 4444 KB Output is correct
15 Correct 1 ms 4444 KB Output is correct
16 Correct 1 ms 4552 KB Output is correct
17 Correct 1 ms 4444 KB Output is correct
18 Correct 1 ms 4540 KB Output is correct
19 Correct 1 ms 4444 KB Output is correct
20 Correct 1 ms 4444 KB Output is correct
21 Correct 1 ms 4444 KB Output is correct
22 Correct 1 ms 4444 KB Output is correct
23 Correct 1 ms 4444 KB Output is correct
24 Correct 1 ms 4444 KB Output is correct
25 Correct 1 ms 4444 KB Output is correct
26 Correct 1 ms 4444 KB Output is correct
27 Correct 1 ms 4444 KB Output is correct
28 Correct 1 ms 4444 KB Output is correct
29 Correct 1 ms 4444 KB Output is correct
30 Correct 1 ms 4444 KB Output is correct
31 Correct 1 ms 4444 KB Output is correct
32 Correct 1 ms 4444 KB Output is correct
33 Correct 1 ms 4532 KB Output is correct
34 Correct 1 ms 4440 KB Output is correct
35 Correct 1 ms 4444 KB Output is correct
36 Correct 1 ms 4444 KB Output is correct
37 Correct 1 ms 4444 KB Output is correct
38 Correct 1 ms 4444 KB Output is correct
39 Correct 34 ms 15576 KB Output is correct
40 Correct 37 ms 15972 KB Output is correct
41 Correct 24 ms 11980 KB Output is correct
42 Correct 6 ms 6228 KB Output is correct
43 Correct 1 ms 4440 KB Output is correct
44 Correct 1 ms 4444 KB Output is correct
45 Correct 1 ms 4444 KB Output is correct
46 Correct 1 ms 4444 KB Output is correct
47 Correct 1 ms 4444 KB Output is correct
48 Correct 1 ms 4444 KB Output is correct
49 Correct 1 ms 4444 KB Output is correct
50 Correct 1 ms 4444 KB Output is correct
51 Correct 1 ms 4444 KB Output is correct
52 Correct 1 ms 4444 KB Output is correct
53 Correct 1 ms 4444 KB Output is correct
54 Correct 1 ms 4692 KB Output is correct
55 Correct 1 ms 4444 KB Output is correct
56 Correct 1 ms 4444 KB Output is correct
57 Correct 48 ms 9328 KB Output is correct
58 Correct 36 ms 9208 KB Output is correct
59 Correct 38 ms 9296 KB Output is correct
60 Correct 36 ms 9296 KB Output is correct
61 Correct 38 ms 9300 KB Output is correct
62 Correct 37 ms 9296 KB Output is correct
63 Correct 34 ms 9040 KB Output is correct
64 Correct 36 ms 9044 KB Output is correct
65 Correct 36 ms 9296 KB Output is correct
66 Correct 36 ms 9300 KB Output is correct
67 Correct 37 ms 9364 KB Output is correct
68 Correct 37 ms 9044 KB Output is correct
69 Correct 37 ms 9400 KB Output is correct
70 Correct 39 ms 9368 KB Output is correct
71 Correct 1 ms 4440 KB Output is correct
72 Correct 2 ms 4700 KB Output is correct
73 Correct 2 ms 4700 KB Output is correct
74 Correct 2 ms 4700 KB Output is correct
75 Correct 2 ms 4700 KB Output is correct
76 Correct 2 ms 4700 KB Output is correct
77 Correct 2 ms 4700 KB Output is correct
78 Correct 2 ms 4444 KB Output is correct
79 Correct 2 ms 4700 KB Output is correct
80 Correct 42 ms 9808 KB Output is correct
81 Correct 41 ms 9228 KB Output is correct
82 Correct 36 ms 9224 KB Output is correct
83 Correct 42 ms 8936 KB Output is correct
84 Correct 1 ms 4444 KB Output is correct
85 Correct 2 ms 4444 KB Output is correct
86 Correct 2 ms 4444 KB Output is correct
87 Correct 2 ms 4440 KB Output is correct
88 Correct 2 ms 4640 KB Output is correct
89 Correct 2 ms 4440 KB Output is correct
90 Correct 2 ms 4444 KB Output is correct
91 Correct 2 ms 4440 KB Output is correct
92 Correct 2 ms 4444 KB Output is correct
93 Correct 2 ms 4440 KB Output is correct
94 Correct 1 ms 4440 KB Output is correct
95 Correct 1 ms 4444 KB Output is correct
96 Correct 1 ms 4444 KB Output is correct
97 Correct 1 ms 4444 KB Output is correct
98 Correct 1 ms 4444 KB Output is correct
99 Correct 1 ms 4444 KB Output is correct
100 Correct 1 ms 4444 KB Output is correct
101 Correct 1 ms 4444 KB Output is correct
102 Correct 1 ms 4444 KB Output is correct
103 Correct 1 ms 4596 KB Output is correct
104 Correct 4 ms 5300 KB Output is correct
105 Correct 9 ms 7004 KB Output is correct
106 Correct 1 ms 4440 KB Output is correct
107 Correct 16 ms 8028 KB Output is correct
108 Correct 25 ms 9876 KB Output is correct
109 Correct 1 ms 4444 KB Output is correct
110 Correct 29 ms 11308 KB Output is correct
111 Correct 33 ms 13528 KB Output is correct
112 Correct 1 ms 4440 KB Output is correct
113 Correct 48 ms 16432 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 15 ms 7260 KB Output is correct
2 Incorrect 16 ms 7388 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4444 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 1 ms 4552 KB Output is correct
4 Correct 1 ms 4444 KB Output is correct
5 Correct 1 ms 4540 KB Output is correct
6 Correct 1 ms 4444 KB Output is correct
7 Correct 1 ms 4444 KB Output is correct
8 Correct 1 ms 4444 KB Output is correct
9 Correct 1 ms 4444 KB Output is correct
10 Correct 1 ms 4444 KB Output is correct
11 Correct 1 ms 4444 KB Output is correct
12 Correct 1 ms 4444 KB Output is correct
13 Correct 1 ms 4444 KB Output is correct
14 Correct 1 ms 4444 KB Output is correct
15 Correct 1 ms 4444 KB Output is correct
16 Correct 1 ms 4444 KB Output is correct
17 Correct 1 ms 4444 KB Output is correct
18 Correct 1 ms 4444 KB Output is correct
19 Correct 1 ms 4444 KB Output is correct
20 Correct 1 ms 4532 KB Output is correct
21 Correct 1 ms 4440 KB Output is correct
22 Correct 1 ms 4444 KB Output is correct
23 Correct 1 ms 4444 KB Output is correct
24 Correct 1 ms 4444 KB Output is correct
25 Correct 1 ms 4444 KB Output is correct
26 Correct 2 ms 4444 KB Output is correct
27 Correct 2 ms 4444 KB Output is correct
28 Correct 2 ms 4444 KB Output is correct
29 Correct 1 ms 4444 KB Output is correct
30 Correct 2 ms 4444 KB Output is correct
31 Correct 2 ms 4444 KB Output is correct
32 Incorrect 1 ms 4444 KB Output isn't correct
33 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 34 ms 15572 KB Output is correct
2 Correct 33 ms 15832 KB Output is correct
3 Correct 25 ms 11984 KB Output is correct
4 Correct 6 ms 6236 KB Output is correct
5 Correct 5 ms 5212 KB Output is correct
6 Correct 9 ms 7112 KB Output is correct
7 Correct 1 ms 4444 KB Output is correct
8 Correct 16 ms 8268 KB Output is correct
9 Correct 21 ms 9884 KB Output is correct
10 Correct 1 ms 4444 KB Output is correct
11 Correct 29 ms 11072 KB Output is correct
12 Correct 34 ms 13352 KB Output is correct
13 Correct 1 ms 4444 KB Output is correct
14 Correct 2 ms 4444 KB Output is correct
15 Correct 1 ms 4444 KB Output is correct
16 Correct 1 ms 4552 KB Output is correct
17 Correct 1 ms 4444 KB Output is correct
18 Correct 1 ms 4540 KB Output is correct
19 Correct 1 ms 4444 KB Output is correct
20 Correct 1 ms 4444 KB Output is correct
21 Correct 1 ms 4444 KB Output is correct
22 Correct 1 ms 4444 KB Output is correct
23 Correct 1 ms 4444 KB Output is correct
24 Correct 1 ms 4444 KB Output is correct
25 Correct 1 ms 4444 KB Output is correct
26 Correct 1 ms 4444 KB Output is correct
27 Correct 1 ms 4444 KB Output is correct
28 Correct 1 ms 4444 KB Output is correct
29 Correct 1 ms 4444 KB Output is correct
30 Correct 1 ms 4444 KB Output is correct
31 Correct 1 ms 4444 KB Output is correct
32 Correct 1 ms 4444 KB Output is correct
33 Correct 1 ms 4532 KB Output is correct
34 Correct 1 ms 4440 KB Output is correct
35 Correct 1 ms 4444 KB Output is correct
36 Correct 1 ms 4444 KB Output is correct
37 Correct 1 ms 4444 KB Output is correct
38 Correct 1 ms 4444 KB Output is correct
39 Correct 34 ms 15576 KB Output is correct
40 Correct 37 ms 15972 KB Output is correct
41 Correct 24 ms 11980 KB Output is correct
42 Correct 6 ms 6228 KB Output is correct
43 Correct 1 ms 4440 KB Output is correct
44 Correct 1 ms 4444 KB Output is correct
45 Correct 1 ms 4444 KB Output is correct
46 Correct 1 ms 4444 KB Output is correct
47 Correct 1 ms 4444 KB Output is correct
48 Correct 1 ms 4444 KB Output is correct
49 Correct 1 ms 4444 KB Output is correct
50 Correct 1 ms 4444 KB Output is correct
51 Correct 1 ms 4444 KB Output is correct
52 Correct 1 ms 4444 KB Output is correct
53 Correct 1 ms 4444 KB Output is correct
54 Correct 1 ms 4692 KB Output is correct
55 Correct 1 ms 4444 KB Output is correct
56 Correct 1 ms 4444 KB Output is correct
57 Correct 48 ms 9328 KB Output is correct
58 Correct 36 ms 9208 KB Output is correct
59 Correct 38 ms 9296 KB Output is correct
60 Correct 36 ms 9296 KB Output is correct
61 Correct 38 ms 9300 KB Output is correct
62 Correct 37 ms 9296 KB Output is correct
63 Correct 34 ms 9040 KB Output is correct
64 Correct 36 ms 9044 KB Output is correct
65 Correct 36 ms 9296 KB Output is correct
66 Correct 36 ms 9300 KB Output is correct
67 Correct 37 ms 9364 KB Output is correct
68 Correct 37 ms 9044 KB Output is correct
69 Correct 37 ms 9400 KB Output is correct
70 Correct 39 ms 9368 KB Output is correct
71 Correct 1 ms 4440 KB Output is correct
72 Correct 2 ms 4700 KB Output is correct
73 Correct 2 ms 4700 KB Output is correct
74 Correct 2 ms 4700 KB Output is correct
75 Correct 2 ms 4700 KB Output is correct
76 Correct 2 ms 4700 KB Output is correct
77 Correct 2 ms 4700 KB Output is correct
78 Correct 2 ms 4444 KB Output is correct
79 Correct 2 ms 4700 KB Output is correct
80 Correct 42 ms 9808 KB Output is correct
81 Correct 41 ms 9228 KB Output is correct
82 Correct 36 ms 9224 KB Output is correct
83 Correct 42 ms 8936 KB Output is correct
84 Correct 1 ms 4444 KB Output is correct
85 Correct 2 ms 4444 KB Output is correct
86 Correct 2 ms 4444 KB Output is correct
87 Correct 2 ms 4440 KB Output is correct
88 Correct 2 ms 4640 KB Output is correct
89 Correct 2 ms 4440 KB Output is correct
90 Correct 2 ms 4444 KB Output is correct
91 Correct 2 ms 4440 KB Output is correct
92 Correct 2 ms 4444 KB Output is correct
93 Correct 2 ms 4440 KB Output is correct
94 Correct 1 ms 4440 KB Output is correct
95 Correct 1 ms 4444 KB Output is correct
96 Correct 1 ms 4444 KB Output is correct
97 Correct 1 ms 4444 KB Output is correct
98 Correct 1 ms 4444 KB Output is correct
99 Correct 1 ms 4444 KB Output is correct
100 Correct 1 ms 4444 KB Output is correct
101 Correct 1 ms 4444 KB Output is correct
102 Correct 1 ms 4444 KB Output is correct
103 Correct 1 ms 4596 KB Output is correct
104 Correct 4 ms 5300 KB Output is correct
105 Correct 9 ms 7004 KB Output is correct
106 Correct 1 ms 4440 KB Output is correct
107 Correct 16 ms 8028 KB Output is correct
108 Correct 25 ms 9876 KB Output is correct
109 Correct 1 ms 4444 KB Output is correct
110 Correct 29 ms 11308 KB Output is correct
111 Correct 33 ms 13528 KB Output is correct
112 Correct 1 ms 4440 KB Output is correct
113 Correct 48 ms 16432 KB Output is correct
114 Correct 15 ms 7260 KB Output is correct
115 Incorrect 16 ms 7388 KB Output isn't correct
116 Halted 0 ms 0 KB -