답안 #289250

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
289250 2020-09-02T13:41:51 Z b00n0rp 꿈 (IOI13_dreaming) C++17
18 / 100
61 ms 12020 KB
#include "dreaming.h"
#include<bits/stdc++.h>
using namespace std;

#define pii pair<int,int>
#define F first
#define S second
#define pb push_back
#define all(v) v.begin(),v.end()

const int MAXN = 100005;

vector<pii> adj[MAXN];
int dp[MAXN],dp_par[MAXN];

bitset<MAXN> vis;
vector<int> cc;

void dfs(int u,int p){
	cc.pb(u);
	vis[u] = 1;
	dp[u] = 0;
	for(auto v:adj[u]){
		if(v.F != p){
			dfs(v.F,u);
			dp[u] = max(dp[u],v.S+dp[v.F]);
		}
	}
}

void dfs_par(int u,int p){
	int mx1 = dp_par[u],mx2 = 0;
	for(auto v:adj[u]){
		if(v.F != p){
			int val = dp[v.F]+v.S;
			if(val > mx1){
				mx2 = mx1;
				mx1 = val;
			}
			else if(val > mx2) mx2 = val;
		}
	}
	for(auto v:adj[u]){
		if(v.F == p) continue;
		
		if(dp[v.F]+v.S == mx1) dp_par[v.F] = mx2;
		else dp_par[v.F] = mx1;
		
		dp_par[v.F] += v.S;
		dfs_par(v.F,u);
	}
}

int travelTime(int N, int M, int L, int A[], int B[], int T[]){
    for(int i = 0; i < M; i ++){
    	adj[A[i]].pb({B[i],T[i]});
    	adj[B[i]].pb({A[i],T[i]});
    }
    vector<int> gg;
    vis.reset();
    for(int i = 0; i < N; i ++){
    	if(vis[i]) continue;
    	cc.clear();
    	dfs(i,i);
    	dfs_par(i,i);
    	int mn = max(dp[i],dp_par[i]);
    	for(auto x:cc) mn = min(mn,max(dp[x],dp_par[x]));
    	gg.pb(mn);
    }
	// for(auto x:gg) cout << x << " "; cout << endl;
    sort(all(gg));
    for(int i = 0; i < (int)(gg.size())-1; i++) gg[i] += L;
    sort(all(gg));
	reverse(all(gg));
	if((int)gg.size() == 1) return gg[0];
	else return gg[0]+gg[1];
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 61 ms 12020 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 61 ms 12020 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 61 ms 12020 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 31 ms 6588 KB Output is correct
2 Correct 29 ms 6528 KB Output is correct
3 Correct 27 ms 6528 KB Output is correct
4 Correct 28 ms 6528 KB Output is correct
5 Correct 30 ms 6656 KB Output is correct
6 Correct 31 ms 7032 KB Output is correct
7 Correct 30 ms 6784 KB Output is correct
8 Correct 28 ms 6528 KB Output is correct
9 Correct 29 ms 6528 KB Output is correct
10 Correct 32 ms 6648 KB Output is correct
11 Correct 2 ms 2688 KB Output is correct
12 Correct 8 ms 4092 KB Output is correct
13 Correct 8 ms 4092 KB Output is correct
14 Correct 8 ms 4092 KB Output is correct
15 Correct 8 ms 4092 KB Output is correct
16 Correct 8 ms 3964 KB Output is correct
17 Correct 7 ms 3836 KB Output is correct
18 Correct 8 ms 4092 KB Output is correct
19 Correct 8 ms 4092 KB Output is correct
20 Correct 2 ms 2688 KB Output is correct
21 Correct 2 ms 2688 KB Output is correct
22 Correct 2 ms 2688 KB Output is correct
23 Correct 8 ms 4092 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 61 ms 12020 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 61 ms 12020 KB Output isn't correct
2 Halted 0 ms 0 KB -