답안 #552138

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
552138 2022-04-22T13:24:38 Z CSQ31 꿈 (IOI13_dreaming) C++17
22 / 100
1000 ms 11724 KB
#include "dreaming.h"
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5+1;
vector<pair<int,int>>adj[MAXN];
bool vis[MAXN];
int dep[MAXN],p[MAXN];
vector<int>cc;
int mn = 2e9,ans = 0;
void dfs(int v,int u){
	vis[v] = 1;
	cc.push_back(v);
	for(auto x:adj[v]){
		if(x.first != u){
			dfs(x.first,v);
			dep[v] = max(dep[v],dep[x.first] + x.second);
			
		}
	}
}
void dfs2(int v,int u){
	for(auto x:adj[v]){
		if(x.first != u){
			dfs2(x.first,v);
			dep[v] = max(dep[v],dep[x.first] + x.second);
			
		}
	}
}
void get(int v,int u){
	multiset<int,greater<int>>s;
	s.insert(p[v]);
	for(auto x:adj[v]){
		if(x.first == u)continue;
		s.insert(dep[x.first] + x.second);
	}
	int mx = max(p[v],dep[v]);
	mn = min(mx,mn);
	for(auto x:adj[v]){
		if(x.first == u)continue;
		s.erase(s.find(dep[x.first] + x.second));
		p[x.first] = *s.begin() + x.second;
		get(x.first,v);
		s.insert(dep[x.first] + x.second);
	}
	
}
int travelTime(int N, int M, int L, int A[], int B[], int T[]) {
	for(int i=0;i<M;i++){
		adj[A[i]].push_back({B[i],T[i]});
		adj[B[i]].push_back({A[i],T[i]});
	}
	vector<int>v;
	for(int i=0;i<N;i++){
		if(!vis[i]){
			cc.clear();
			dfs(i,-1);
			mn = 1e9;
			for(int x:cc){
				for(int j=0;j<N;j++)dep[j] = p[j] = 0;
				dfs2(x,-1);
				mn = min(mn,dep[x]);
				ans = max(ans,dep[x]);
			}
			
			v.push_back(mn);
			//cout<<i<<" "<<mn<<'\n';
		}
	}
	//for(int i=0;i<N;i++)cout<<dep[i]<<" ";
	//cout<<'\n';
	//for(int i=0;i<N;i++)cout<<p[i]<<" ";
	//cout<<'\n';
	sort(v.begin(),v.end(),greater<int>());
	if(v.size()>=2)ans = max(ans,v[0] + v[1] + L);
	if(v.size()>=3)ans = max(ans,v[1] + v[2] + 2*L);
	return ans;
}
/*
int main(){
	int n,m,l;
	cin>>n>>m>>l;
	int a[m],b[m],t[m];
	for(int i=0;i<m;i++)cin>>a[i]>>b[i]>>t[i];
	cout<<travelTime(n,m,l,a,b,t);
	
}*/
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1078 ms 11724 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2644 KB Output is correct
2 Correct 2 ms 2644 KB Output is correct
3 Correct 2 ms 2644 KB Output is correct
4 Correct 2 ms 2644 KB Output is correct
5 Correct 2 ms 2644 KB Output is correct
6 Correct 2 ms 2644 KB Output is correct
7 Correct 3 ms 2644 KB Output is correct
8 Correct 2 ms 2644 KB Output is correct
9 Correct 3 ms 2644 KB Output is correct
10 Correct 2 ms 2644 KB Output is correct
11 Correct 2 ms 2660 KB Output is correct
12 Correct 2 ms 2644 KB Output is correct
13 Correct 2 ms 2644 KB Output is correct
14 Correct 2 ms 2660 KB Output is correct
15 Correct 2 ms 2644 KB Output is correct
16 Correct 2 ms 2644 KB Output is correct
17 Correct 2 ms 2644 KB Output is correct
18 Correct 2 ms 2644 KB Output is correct
19 Correct 2 ms 2664 KB Output is correct
20 Correct 2 ms 2644 KB Output is correct
21 Correct 2 ms 2644 KB Output is correct
22 Correct 2 ms 2660 KB Output is correct
23 Correct 2 ms 2644 KB Output is correct
24 Correct 2 ms 2644 KB Output is correct
25 Correct 2 ms 2644 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1078 ms 11724 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1083 ms 6372 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2644 KB Output is correct
2 Correct 2 ms 2644 KB Output is correct
3 Correct 2 ms 2644 KB Output is correct
4 Correct 2 ms 2644 KB Output is correct
5 Correct 2 ms 2644 KB Output is correct
6 Correct 2 ms 2644 KB Output is correct
7 Correct 3 ms 2644 KB Output is correct
8 Correct 2 ms 2644 KB Output is correct
9 Correct 3 ms 2644 KB Output is correct
10 Correct 2 ms 2644 KB Output is correct
11 Correct 2 ms 2660 KB Output is correct
12 Correct 2 ms 2644 KB Output is correct
13 Correct 2 ms 2644 KB Output is correct
14 Correct 2 ms 2660 KB Output is correct
15 Correct 2 ms 2644 KB Output is correct
16 Correct 2 ms 2644 KB Output is correct
17 Correct 2 ms 2644 KB Output is correct
18 Correct 2 ms 2644 KB Output is correct
19 Correct 2 ms 2664 KB Output is correct
20 Correct 2 ms 2644 KB Output is correct
21 Correct 2 ms 2644 KB Output is correct
22 Correct 2 ms 2660 KB Output is correct
23 Correct 2 ms 2644 KB Output is correct
24 Correct 2 ms 2644 KB Output is correct
25 Correct 2 ms 2644 KB Output is correct
26 Correct 2 ms 2644 KB Output is correct
27 Correct 5 ms 2772 KB Output is correct
28 Correct 6 ms 2772 KB Output is correct
29 Correct 2 ms 2644 KB Output is correct
30 Correct 4 ms 2772 KB Output is correct
31 Correct 6 ms 2772 KB Output is correct
32 Correct 3 ms 2772 KB Output is correct
33 Correct 5 ms 2772 KB Output is correct
34 Correct 7 ms 2880 KB Output is correct
35 Correct 2 ms 2644 KB Output is correct
36 Correct 2 ms 2644 KB Output is correct
37 Correct 2 ms 2664 KB Output is correct
38 Correct 2 ms 2644 KB Output is correct
39 Correct 2 ms 2668 KB Output is correct
40 Correct 2 ms 2660 KB Output is correct
41 Correct 3 ms 2644 KB Output is correct
42 Correct 2 ms 2644 KB Output is correct
43 Correct 2 ms 2644 KB Output is correct
44 Correct 2 ms 2644 KB Output is correct
45 Correct 2 ms 2644 KB Output is correct
46 Correct 2 ms 2644 KB Output is correct
47 Correct 3 ms 2660 KB Output is correct
48 Correct 2 ms 2644 KB Output is correct
49 Correct 2 ms 2644 KB Output is correct
50 Correct 2 ms 2644 KB Output is correct
51 Correct 2 ms 2660 KB Output is correct
52 Correct 2 ms 2644 KB Output is correct
53 Correct 3 ms 2652 KB Output is correct
54 Correct 189 ms 3104 KB Output is correct
55 Correct 189 ms 3088 KB Output is correct
56 Correct 4 ms 2832 KB Output is correct
57 Correct 4 ms 2772 KB Output is correct
58 Correct 66 ms 2892 KB Output is correct
59 Correct 103 ms 2900 KB Output is correct
60 Correct 6 ms 2772 KB Output is correct
61 Correct 4 ms 2772 KB Output is correct
62 Correct 65 ms 2888 KB Output is correct
63 Correct 61 ms 2900 KB Output is correct
64 Correct 4 ms 2664 KB Output is correct
65 Correct 5 ms 2808 KB Output is correct
66 Correct 131 ms 2904 KB Output is correct
67 Correct 65 ms 2900 KB Output is correct
68 Correct 4 ms 2828 KB Output is correct
69 Correct 5 ms 2772 KB Output is correct
70 Correct 4 ms 2676 KB Output is correct
71 Correct 4 ms 2672 KB Output is correct
72 Correct 106 ms 2844 KB Output is correct
73 Correct 101 ms 2900 KB Output is correct
74 Correct 6 ms 2772 KB Output is correct
75 Correct 9 ms 2884 KB Output is correct
76 Correct 80 ms 2900 KB Output is correct
77 Correct 93 ms 2912 KB Output is correct
78 Correct 4 ms 2772 KB Output is correct
79 Correct 4 ms 2772 KB Output is correct
80 Correct 4 ms 2644 KB Output is correct
81 Correct 3 ms 2644 KB Output is correct
82 Correct 5 ms 2772 KB Output is correct
83 Correct 8 ms 2772 KB Output is correct
84 Correct 11 ms 2788 KB Output is correct
85 Correct 4 ms 2644 KB Output is correct
86 Correct 40 ms 2832 KB Output is correct
87 Correct 95 ms 2772 KB Output is correct
88 Correct 7 ms 2764 KB Output is correct
89 Correct 4 ms 2772 KB Output is correct
90 Correct 4 ms 2680 KB Output is correct
91 Correct 4 ms 2772 KB Output is correct
92 Correct 27 ms 2804 KB Output is correct
93 Correct 32 ms 2828 KB Output is correct
94 Correct 34 ms 2800 KB Output is correct
95 Correct 51 ms 2772 KB Output is correct
96 Correct 44 ms 2860 KB Output is correct
97 Correct 41 ms 2772 KB Output is correct
98 Correct 48 ms 2860 KB Output is correct
99 Correct 91 ms 2900 KB Output is correct
100 Correct 62 ms 2772 KB Output is correct
101 Correct 61 ms 2860 KB Output is correct
102 Correct 2 ms 2664 KB Output is correct
103 Correct 2 ms 2644 KB Output is correct
104 Correct 2 ms 2644 KB Output is correct
105 Correct 2 ms 2644 KB Output is correct
106 Correct 2 ms 2644 KB Output is correct
107 Correct 2 ms 2656 KB Output is correct
108 Correct 2 ms 2644 KB Output is correct
109 Correct 2 ms 2668 KB Output is correct
110 Correct 2 ms 2644 KB Output is correct
111 Correct 2 ms 2644 KB Output is correct
112 Correct 3 ms 2644 KB Output is correct
113 Correct 7 ms 2676 KB Output is correct
114 Correct 10 ms 2772 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1078 ms 11724 KB Time limit exceeded
2 Halted 0 ms 0 KB -