답안 #163210

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
163210 2019-11-11T18:44:50 Z kostia244 꿈 (IOI13_dreaming) C++17
0 / 100
70 ms 21752 KB
#define _GLIBCXX_DEBUG
#include "dreaming.h"
#include<bits/stdc++.h>
#define all(x) x.begin(), x.end()
#define pb push_back
using namespace std;
using ll = long long;
using vi = vector<ll>;
using vvi = vector<vi>;
using pi = pair<ll, ll>;
using vpi = vector<pi>;
using vvpi = vector<vpi>;
int n;
vvpi g;
vi diams, comp;
bitset<5000> vis;
void dc(int v) {
	comp.pb(v);
	vis.set(v);
	for(auto i : g[v])
		if(!vis.test(i.first)) dc(i.first);
}
ll dfs(int v, int p) {
	ll x=0;
	for(auto i : g[v])
		if(i.first!=p) x = max(x, i.second+dfs(i.first, v));
	return x;
}
int travelTime(int N, int M, int L, int A[], int B[], int T[]) {
	n = N;
	g.resize(n);
	ll ans = 0;
//	cout << N << " " << M << "\n";
//	return 0;
	for(int f, t, c, i = 0; i < M; i++) {
		f = A[i], t = A[i], c = T[i];
//		cout <<f << " " << t << "\n";
		g[f].pb({t, c});
		g[t].pb({f, c});
	}
	for(int i = 0; i < n; i++) {
		if(!vis[i]) {
			comp.clear();
			dc(i);
			ll d = 0;
			for(auto j : comp)
				d = max(d, dfs(j, j));
			diams.pb(d);
		}
	}
	sort(all(diams));
	if(diams.size()==1)ans=diams[0];
	else ans = diams[0]+L+diams[1];
	if(diams.size()>2) ans = max(ans, diams[2]+L+L+diams[1]);
	return ans;
}
# 결과 실행 시간 메모리 Grader output
1 Runtime error 70 ms 21752 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 70 ms 21752 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 70 ms 21752 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 36 ms 14788 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 70 ms 21752 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 70 ms 21752 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -