답안 #552124

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
552124 2022-04-22T13:04:03 Z CSQ31 꿈 (IOI13_dreaming) C++17
32 / 100
93 ms 21012 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];
int mn = 2e9,ans = 0;
void dfs(int v,int u){
	vis[v] = 1;
	for(auto x:adj[v]){
		if(x.first != u){
			dfs(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(0);
	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]){
			mn = 2e9;
			dfs(i,-1);
			int c = 0;
			for(auto x:adj[i]){
				ans = max(ans,dep[x.first] + c + x.second);
				c = max(c,dep[x.first] + x.second);
			}
			get(i,-1);
			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 Correct 63 ms 20784 KB Output is correct
2 Correct 64 ms 21012 KB Output is correct
3 Correct 48 ms 20312 KB Output is correct
4 Correct 10 ms 5588 KB Output is correct
5 Correct 11 ms 4052 KB Output is correct
6 Correct 17 ms 6896 KB Output is correct
7 Correct 3 ms 2660 KB Output is correct
8 Correct 35 ms 10416 KB Output is correct
9 Correct 41 ms 16308 KB Output is correct
10 Correct 2 ms 2772 KB Output is correct
11 Correct 60 ms 16112 KB Output is correct
12 Correct 93 ms 18892 KB Output is correct
13 Correct 3 ms 2772 KB Output is correct
# 결과 실행 시간 메모리 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 2 ms 2644 KB Output is correct
8 Correct 2 ms 2656 KB Output is correct
9 Incorrect 2 ms 2644 KB Output isn't correct
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 63 ms 20784 KB Output is correct
2 Correct 64 ms 21012 KB Output is correct
3 Correct 48 ms 20312 KB Output is correct
4 Correct 10 ms 5588 KB Output is correct
5 Correct 11 ms 4052 KB Output is correct
6 Correct 17 ms 6896 KB Output is correct
7 Correct 3 ms 2660 KB Output is correct
8 Correct 35 ms 10416 KB Output is correct
9 Correct 41 ms 16308 KB Output is correct
10 Correct 2 ms 2772 KB Output is correct
11 Correct 60 ms 16112 KB Output is correct
12 Correct 93 ms 18892 KB Output is correct
13 Correct 3 ms 2772 KB Output is correct
14 Correct 2 ms 2644 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 2644 KB Output is correct
20 Correct 2 ms 2644 KB Output is correct
21 Correct 2 ms 2656 KB Output is correct
22 Incorrect 2 ms 2644 KB Output isn't correct
23 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 36 ms 6148 KB Output is correct
2 Correct 28 ms 6160 KB Output is correct
3 Correct 30 ms 6148 KB Output is correct
4 Correct 33 ms 6144 KB Output is correct
5 Correct 25 ms 6100 KB Output is correct
6 Correct 27 ms 6620 KB Output is correct
7 Correct 27 ms 6272 KB Output is correct
8 Correct 24 ms 6104 KB Output is correct
9 Correct 26 ms 6096 KB Output is correct
10 Correct 29 ms 6224 KB Output is correct
11 Correct 1 ms 2588 KB Output is correct
12 Correct 12 ms 3920 KB Output is correct
13 Correct 9 ms 4048 KB Output is correct
14 Correct 10 ms 3920 KB Output is correct
15 Correct 14 ms 3944 KB Output is correct
16 Correct 9 ms 3912 KB Output is correct
17 Correct 9 ms 3536 KB Output is correct
18 Correct 13 ms 4000 KB Output is correct
19 Correct 10 ms 3920 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 2644 KB Output is correct
23 Correct 9 ms 3916 KB Output is correct
# 결과 실행 시간 메모리 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 2 ms 2644 KB Output is correct
8 Correct 2 ms 2656 KB Output is correct
9 Incorrect 2 ms 2644 KB Output isn't correct
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 63 ms 20784 KB Output is correct
2 Correct 64 ms 21012 KB Output is correct
3 Correct 48 ms 20312 KB Output is correct
4 Correct 10 ms 5588 KB Output is correct
5 Correct 11 ms 4052 KB Output is correct
6 Correct 17 ms 6896 KB Output is correct
7 Correct 3 ms 2660 KB Output is correct
8 Correct 35 ms 10416 KB Output is correct
9 Correct 41 ms 16308 KB Output is correct
10 Correct 2 ms 2772 KB Output is correct
11 Correct 60 ms 16112 KB Output is correct
12 Correct 93 ms 18892 KB Output is correct
13 Correct 3 ms 2772 KB Output is correct
14 Correct 2 ms 2644 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 2644 KB Output is correct
20 Correct 2 ms 2644 KB Output is correct
21 Correct 2 ms 2656 KB Output is correct
22 Incorrect 2 ms 2644 KB Output isn't correct
23 Halted 0 ms 0 KB -