답안 #387167

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
387167 2021-04-08T05:40:04 Z milleniumEeee 즐거운 행로 (APIO20_fun) C++17
컴파일 오류
0 ms 0 KB
////////////////////////////////
#include "fun.h"
#include "grader.cpp"
////////////////////////////////
#include <bits/stdc++.h>
#define pb push_back
#define szof(s) (int)s.size()
#define all(s) s.begin(), s.end()
#define fr first
#define sc second
#define pii pair<int, int>
using namespace std;

const int MAXN = (int)1e5 + 5;
const int MAXQ = (int)4e5 + 5;

vector <int> g[MAXN];
bool used[MAXN];
int dist[MAXN];
int n;

void calc(int v, int par, int len) {
	dist[v] = len;
	for (int to : g[v]) {
		if (to == par) {
			continue;
		}
		calc(to, v, len + 1);
	}
}

int get_max() {
	int pos = -1, mx = 0;
	for (int i = 0; i < n; i++) {
		if (!used[i] && dist[i] > mx) {
			mx = dist[i];
			pos = i;
		}
	}
	return pos;
}

vector <int> createFunTour(int N, int Q) {
	n = N;
	for (int i = 0; i < n; i++) {
		for (int j = i + 1; j < n; j++) {
			if (hoursRequired(i, j) == 1) {
				g[i].pb(j);
				g[j].pb(i);
			}
		}
	}
	int a = 1;
	calc(a, -1, 0);
	int b = get_max();
	calc(b, -1, 0);
	int c = get_max();
	vector <int> ans = {b, c};
	used[b] = used[c] = 1;
	int used_cnt = 2;
	int last = c;
	while (used_cnt < n) {
		calc(last, -1, 0);
		int nxt = get_max();
		last = nxt;
		ans.pb(nxt);
		used[last] = 1;
		used_cnt++;
	}
	return ans;
}
/*
8 400000
5 3
1 3
4 3
6 5
2 5
5 0
7 3
*/

Compilation message

/tmp/ccIbyyxd.o: In function `hoursRequired(int, int)':
grader.cpp:(.text+0x220): multiple definition of `hoursRequired(int, int)'
/tmp/ccCl3cl4.o:fun.cpp:(.text+0x330): first defined here
/tmp/ccIbyyxd.o: In function `attractionsBehind(int, int)':
grader.cpp:(.text+0x2f0): multiple definition of `attractionsBehind(int, int)'
/tmp/ccCl3cl4.o:fun.cpp:(.text+0x400): first defined here
/tmp/ccIbyyxd.o: In function `my_assert(bool)':
grader.cpp:(.text+0x490): multiple definition of `my_assert(bool)'
/tmp/ccCl3cl4.o:fun.cpp:(.text+0x5a0): first defined here
/tmp/ccIbyyxd.o: In function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'
/tmp/ccCl3cl4.o:fun.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status