제출 #724927

#제출 시각아이디문제언어결과실행 시간메모리
724927hollwo_pelw즐거운 행로 (APIO20_fun)C++17
컴파일 에러
0 ms0 KiB
#include "fun.h" #include "grader.cpp" #include <bits/stdc++.h> using namespace std; vector<int> createFunTour(int N, int Q) { int centroid = 0, tmp = N; for (int i = 1; i < N; i++) { int siz = attractionsBehind(0, i); if (siz > N / 2 && siz < tmp) centroid = i, tmp = siz; } vector<int> depth(N, 0), group(N, 0); for (int i = 0; i < N; i++) if (i != centroid) { depth[i] = hoursRequired(centroid, i); } vector<int> branch; for (int i = 0; i < N; i++) if (depth[i] == 1) branch.push_back(i); int M = branch.size(); for (int i = 0; i < N; i++) if (i != centroid) { for (int j = 1; j < M; j++) if (hoursRequired(branch[j], i) == depth[i] - 1) { group[i] = j; break; } } vector<vector<int>> list_val(M = 3); for (int i = 0; i < N; i++) if (i != centroid) { list_val[group[i]].push_back(i); } for (int i = 0; i < M; i++) { sort(list_val[i].begin(), list_val[i].end(), [&](const int &i, const int &j){ return depth[i] < depth[j]; }); } vector<int> res, p = {0, 1, 2}; int last = -1; while (true) { sort(p.begin(), p.end(), [&](const int &i, const int &j){ return list_val[i].size() > list_val[j].size(); }); if (list_val[p[0]].size() >= list_val[p[1]].size() + list_val[p[2]].size()) break ; for (int i = 0; i < 3; i++) assert(!list_val[i].empty()); sort(p.begin(), p.end(), [&](const int &i, const int &j){ return depth[list_val[i].back()] > depth[list_val[j].back()]; }); int cur = last == p[0] ? p[1] : p[0]; res.push_back(list_val[cur].back()); list_val[cur].pop_back(), last = cur; } list_val[p[1]].insert(list_val[p[1]].end(), list_val[p[2]].begin(), list_val[p[2]].end()); sort(list_val[p[1]].begin(), list_val[p[1]].end(), [&](const int &i, const int &j){ return depth[i] < depth[j]; }); last = ((int) res.size() >= 2 && group[res[res.size() - 2]] != p[0] && depth[res[res.size() - 2]] > depth[res.back()] && depth[list_val[p[1]].back()] > depth[res.back()] ) ? 1 : 0; for (; list_val[p[last]].size(); last ^= 1) { res.push_back(list_val[p[last]].back()); list_val[p[last]].pop_back(); } res.push_back(centroid); return res; }

컴파일 시 표준 에러 (stderr) 메시지

/usr/bin/ld: /tmp/cc4MNlbY.o: in function `hoursRequired(int, int)':
grader.cpp:(.text+0x1f0): multiple definition of `hoursRequired(int, int)'; /tmp/cckDYYbZ.o:fun.cpp:(.text+0x14a0): first defined here
/usr/bin/ld: /tmp/cc4MNlbY.o: in function `attractionsBehind(int, int)':
grader.cpp:(.text+0x300): multiple definition of `attractionsBehind(int, int)'; /tmp/cckDYYbZ.o:fun.cpp:(.text+0x15b0): first defined here
/usr/bin/ld: /tmp/cc4MNlbY.o: in function `my_assert(bool)':
grader.cpp:(.text+0x4c0): multiple definition of `my_assert(bool)'; /tmp/cckDYYbZ.o:fun.cpp:(.text+0x1770): first defined here
/usr/bin/ld: /tmp/cc4MNlbY.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/cckDYYbZ.o:fun.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status