답안 #290722

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
290722 2020-09-04T11:04:28 Z AKaan37 꿈 (IOI13_dreaming) C++17
18 / 100
87 ms 27384 KB
//Bismillahirrahmanirrahim
#include "dreaming.h"
#include <bits/stdc++.h>

using namespace std;

typedef long long lo;
typedef pair< int,int > PII;

#define fi first
#define se second
#define mp make_pair
#define endl "\n"
#define pb push_back
#define fio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define FOR for(int i=0;i<n;i++)
#define mid ((start+end)/2)
#define ort ((bas+son)/2)

const lo inf = 2000000000;
const lo KOK = 100000;
const lo LOG = 30;
const lo li = 500005;
const lo mod = 1000000007;

int n,m,b[li],a[li],k,flag,t,co[li],vis[li],mx[li],mn;
int cev;
string s;
vector<PII> v[li];
vector<int> vec;
//~ int A[li],B[li],T[li];

inline void dfs(int node,int ata){
	vis[node]=1;
	int mx1=0,mx2=0;
	for(int i=0;i<(int)v[node].size();i++){
		int go=v[node][i].fi;
		if(go==ata)continue;
		dfs(go,node);
		co[node]=max(co[node],co[go]+v[node][i].se);
		mx2=max(mx2,co[go]+v[node][i].se);
		if(mx2>mx1)swap(mx1,mx2);
	}
	cev=max(cev,mx1+mx2);
	//~ cout<<node<<endl;
	mx[node]=max(mx[node],co[node]);
}

inline void dfs1(int node,int ata,int der){
	vis[node]=1;
	multiset<int> st;
	for(int i=0;i<(int)v[node].size();i++){
		int go=v[node][i].fi;
		if(go==ata)continue;
		st.insert(co[go]+v[node][i].se);
	}
	int der1=der;
	
	for(int i=0;i<(int)v[node].size();i++){
		int go=v[node][i].fi;
		if(go==ata)continue;
		auto it=st.end();
		it--;
		if(*it==co[go]+v[node][i].se){
			if(it!=st.begin()){
				it--;
				der1=max(der1,*it);
			}
		}
		else der1=max(der1,*it);
		dfs1(go,node,der1+v[node][i].se);
	}
	mx[node]=max(mx[node],der1);
	//~ cev=max(cev,mx[node]);
	mn=min(mn,mx[node]);
}

int travelTime(int n, int m, int l, int A[], int B[], int T[]) {
    for(int i=0;i<m;i++){
		v[A[i]].pb({B[i],T[i]});
		v[B[i]].pb({A[i],T[i]});
	}
    FOR{
		if(vis[i])continue;
		mn=inf;
		dfs(i,-1);
		dfs1(i,-1,0);
		vec.pb(mn);
	}
	sort(vec.begin(),vec.end());
	reverse(vec.begin(),vec.end());
	//~ for(int i=0;i<(int)vec.size();i++)cout<<vec[i]<<endl;
	for(int i=1;i<(int)vec.size();i++){
		cev=max(cev,vec[0]+vec[i]+l);
	}
	for(int i=2;i<(int)vec.size();i++){
		cev=max(cev,vec[1]+vec[i]+2*l);
	}
	return cev;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 87 ms 27384 KB Output is correct
2 Correct 87 ms 26616 KB Output is correct
3 Correct 60 ms 26744 KB Output is correct
4 Correct 18 ms 14464 KB Output is correct
5 Correct 15 ms 13312 KB Output is correct
6 Correct 25 ms 15740 KB Output is correct
7 Incorrect 9 ms 12160 KB Output isn't correct
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 87 ms 27384 KB Output is correct
2 Correct 87 ms 26616 KB Output is correct
3 Correct 60 ms 26744 KB Output is correct
4 Correct 18 ms 14464 KB Output is correct
5 Correct 15 ms 13312 KB Output is correct
6 Correct 25 ms 15740 KB Output is correct
7 Incorrect 9 ms 12160 KB Output isn't correct
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 87 ms 27384 KB Output is correct
2 Correct 87 ms 26616 KB Output is correct
3 Correct 60 ms 26744 KB Output is correct
4 Correct 18 ms 14464 KB Output is correct
5 Correct 15 ms 13312 KB Output is correct
6 Correct 25 ms 15740 KB Output is correct
7 Incorrect 9 ms 12160 KB Output isn't correct
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 37 ms 15860 KB Output is correct
2 Correct 40 ms 16000 KB Output is correct
3 Correct 35 ms 15864 KB Output is correct
4 Correct 36 ms 15864 KB Output is correct
5 Correct 35 ms 15864 KB Output is correct
6 Correct 37 ms 16376 KB Output is correct
7 Correct 38 ms 16248 KB Output is correct
8 Correct 36 ms 15864 KB Output is correct
9 Correct 36 ms 15732 KB Output is correct
10 Correct 37 ms 15988 KB Output is correct
11 Correct 8 ms 12160 KB Output is correct
12 Correct 12 ms 13820 KB Output is correct
13 Correct 14 ms 13820 KB Output is correct
14 Correct 12 ms 13820 KB Output is correct
15 Correct 12 ms 13820 KB Output is correct
16 Correct 12 ms 13820 KB Output is correct
17 Correct 12 ms 13564 KB Output is correct
18 Correct 12 ms 13820 KB Output is correct
19 Correct 12 ms 13820 KB Output is correct
20 Correct 8 ms 12032 KB Output is correct
21 Correct 8 ms 12032 KB Output is correct
22 Correct 8 ms 12160 KB Output is correct
23 Correct 12 ms 13820 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 87 ms 27384 KB Output is correct
2 Correct 87 ms 26616 KB Output is correct
3 Correct 60 ms 26744 KB Output is correct
4 Correct 18 ms 14464 KB Output is correct
5 Correct 15 ms 13312 KB Output is correct
6 Correct 25 ms 15740 KB Output is correct
7 Incorrect 9 ms 12160 KB Output isn't correct
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 87 ms 27384 KB Output is correct
2 Correct 87 ms 26616 KB Output is correct
3 Correct 60 ms 26744 KB Output is correct
4 Correct 18 ms 14464 KB Output is correct
5 Correct 15 ms 13312 KB Output is correct
6 Correct 25 ms 15740 KB Output is correct
7 Incorrect 9 ms 12160 KB Output isn't correct
8 Halted 0 ms 0 KB -