답안 #932401

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
932401 2024-02-23T09:37:42 Z pan 꿈 (IOI13_dreaming) C++17
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//#include "bits_stdc++.h"
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define input(x) scanf("%lld", &x);
#define input2(x, y) scanf("%lld%lld", &x, &y);
#define input3(x, y, z) scanf("%lld%lld%lld", &x, &y, &z);
#define input4(x, y, z, a) scanf("%lld%lld%lld%lld", &x, &y, &z, &a);
#define print(x, y) printf("%lld%c", x, y);
#define show(x) cerr << #x << " is " << x << endl;
#define show2(x,y) cerr << #x << " is " << x << " " << #y << " is " << y << endl;
#define show3(x,y,z) cerr << #x << " is " << x << " " << #y << " is " << y << " " << #z << " is " << z << endl;
#define discretize(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
using namespace std;
//using namespace __gnu_pbds;
//#define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
//#define ordered_multiset tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update>
typedef long long ll;
typedef long double ld;
typedef pair<ld, ll> pd;
typedef pair<string, ll> psl;
typedef pair<ll, ll> pi;
typedef pair<ll, pi> pii;
ll n, m, l, counter = 0, farest, dis, dia = 0;
ll const INF =1e13;
vector<ll> radii;
vector<pi> adj[100005];
vector<ll> dist(100005, -1);
vector<ll> visited;
bool joined[100005];
vector<ll> cc;
void dfs(ll from)
{
	if (!joined[from])  cc.pb(from);
	joined[from] = true;
	visited[from] = true;
	for (pi u: adj[from])
	{
		if (visited[u.f] ) continue;
		visited[u.f] = true;
		dist[u.f] = dist[from] + u.s;
		if (dist[u.f]>dis) {dis= dist[u.f], farest = u.f;}
		dfs(u.f);
	}
	
}
void reset() 
{
	visited.assign(n, false);
	dist.assign(100005, INF);
}
int travelTime(int N, int M, int L, int A[], int B[], int T[])
{
	n = N, m = M, l = L;
	for (ll i=0; i<m; ++i)
	{
		adj[A[i]].pb(mp(B[i], T[i]));
		adj[B[i]].pb(mp(A[i], T[i]));
	}
	for (ll i=0; i<n; ++i)
	{
		if (joined[i]) continue;
		counter++;
		cc.clear();
		reset();
		dist[i] = 0;
		farest = i;
		dis= 0 ;
		dfs(i);
		ll first = farest;
		reset();
		dist[first] = 0;
		dis=0;
		farest = first;
		dfs(first);
		ll second = farest;
		vector<ll> dist1= dist;
		dia = max(dia, dis);
		reset();
		dist[second] = 0;
		dfs(second);
		vector<ll> dist2 = dist;
		ll radius = LLONG_MAX/2;
		for (ll j=0; j<cc.size(); ++j)
		{
			radius = min(radius, max(dist1[cc[j]], dist2[cc[j]]));
		}
		radii.pb(radius);
	}
	if (n==1) return 0;
	if (n==2) return (m==1)?dia:l;
	sort(radii.begin(), radii.end(), greater<ll>());
	ll ans = dia;
	if (counter>1) ans = max(ans, radii[0] + radii[1]+ l);
	if (counter>2) ans = max(ans, radii[1] + radii[2]+ 2*l);
	return ans;
	return 0;
}


Compilation message

dreaming.cpp: In function 'int travelTime(int, int, int, int*, int*, int*)':
dreaming.cpp:90:17: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   90 |   for (ll j=0; j<cc.size(); ++j)
      |                ~^~~~~~~~~~
/usr/bin/ld: /tmp/ccqkxdeU.o: in function `main':
grader.c:(.text.startup+0xd1): undefined reference to `travelTime'
collect2: error: ld returned 1 exit status