답안 #105419

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
105419 2019-04-12T06:22:59 Z turbat 꿈 (IOI13_dreaming) C++14
0 / 100
54 ms 10488 KB
#include "dreaming.h"
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
using pii = pair<int, int>;
using vi = vector <int>;
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define ll long long
#define ook order_of_key
#define fbo find_by_order
#define sq(x) (x) * (x)
#define N 100005

vector <pii> edg[N];
multiset <ll> se;
bool vis[N];
ll dist, dp[N];

void dfs(int u){
	vis[u] = 1;
	ll mx = 0;
	for (pii v : edg[u])
		if (!vis[v.F]){
			dfs(v.F);
			if (dp[v.F] + v.S > dp[u]){
				mx = dp[u];
				dp[u] = dp[v.F] + v.S;
			}
			else if (dp[v.F] + v.S > mx) mx = dp[v.F] + v.S;
		}
	dist = max(dist, dp[u] + mx);
}

int travelTime(int n, int m, int L, int A[], int B[], int T[]) {
	for (int i = 0;i < m;i++){
		edg[A[i]].pb(mp(B[i], T[i]));
		edg[B[i]].pb(mp(A[i], T[i]));
	}
	for (int i = 0;i < n;i++)
    	if (!vis[i]){
    		dist = 0;
    		dfs(i);
    		se.insert(dist);
    	}
    while (se.size() > 1){
    	dist = L;
    	dist += *se.begin();
    	se.erase(se.begin());
    	dist += *se.begin();
    	se.erase(se.begin());   	
    	se.insert(dist);
    }
    return *se.begin();
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 54 ms 10488 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 54 ms 10488 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 54 ms 10488 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 48 ms 8696 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 54 ms 10488 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 54 ms 10488 KB Output isn't correct
2 Halted 0 ms 0 KB -