제출 #395286

#제출 시각아이디문제언어결과실행 시간메모리
395286syl123456즐거운 행로 (APIO20_fun)C++17
컴파일 에러
0 ms0 KiB
#include "fun.h"
#include <bits/stdc++.h>
#define all(i) (i).begin(), (i).end()
using namespace std;
typedef pair<int, int> pi;
typedef pair<int, pi> pp;
const int inf = 1 << 30;

template<typename T>
ostream& operator << (ostream &i, vector<T> j) {
    i << '{';
    for (auto ii : j) i << ii << ' ';
    return i << '}';
}
int hoursRequired(int x, int xx) {int xxx;cout << "dis " << x << ' ' << xx << endl;cin >> xxx;return xxx;}
int attractionsBehind(int x, int xx) {int xxx;cout << "sz " << x << ' ' << xx << endl;cin >> xxx;return xxx;}
std::vector<int> createFunTour(int N, int Q) {
    vector<int> dep(N), sz(N);
    dep[0] = 0, sz[0] = N;
    int cen = 0;
    for (int i = 1; i < N; ++i) {
        dep[i] = hoursRequired(0, i);
        sz[i] = attractionsBehind(0, i);
        if (dep[i] > dep[cen] && sz[i] > N / 2) cen = i;
    }
    vector<int> v[3], ch;
    if (cen != 0) for (int i = 0; i < N; ++i) dep[i] = i == cen ? 0 : hoursRequired(cen, i);
    for (int i = 0; i < N; ++i) if (dep[i] == 1) ch.push_back(i);
    for (int j = 0; j < ch.size(); ++j) v[j].push_back(ch[j]);
    for (int i = 0; i < N; ++i) if (dep[i] > 1) {
        bool b = false;
        for (int j = 0; j < ch.size() - 1; ++j) if (dep[i] == 1 + hoursRequired(ch[j], i)) {
            v[j].push_back(i);
            b = true;
            break;
        }
        if (!b) v[ch.size() - 1].push_back(i);
    }
    for (int i = 0; i < 3; ++i) sort(all(v[i]), [&](int x, int y) {
        return dep[x] < dep[y];
    });
    vector<int> ans;
    int pre = -1;
    for (int i = 0; i < N - 1; ++i) {
        int tmp = -1;
        for (int j = 0; j < 3; ++j) if (j != pre && !v[j].empty() && (tmp == -1 || dep[v[j].back()] > dep[v[tmp].back()]))
            tmp = j;
        ans.push_back(v[tmp].back());
        v[tmp].pop_back();
        pre = tmp;
    }
    ans.push_back(cen);
    return ans;
}

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

fun.cpp: In function 'std::vector<int> createFunTour(int, int)':
fun.cpp:29:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   29 |     for (int j = 0; j < ch.size(); ++j) v[j].push_back(ch[j]);
      |                     ~~^~~~~~~~~~~
fun.cpp:32:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   32 |         for (int j = 0; j < ch.size() - 1; ++j) if (dep[i] == 1 + hoursRequired(ch[j], i)) {
      |                         ~~^~~~~~~~~~~~~~~
/tmp/ccsygWs0.o: In function `hoursRequired(int, int)':
grader.cpp:(.text+0x220): multiple definition of `hoursRequired(int, int)'
/tmp/ccBWdAq7.o:fun.cpp:(.text+0x430): first defined here
/tmp/ccsygWs0.o: In function `attractionsBehind(int, int)':
grader.cpp:(.text+0x2f0): multiple definition of `attractionsBehind(int, int)'
/tmp/ccBWdAq7.o:fun.cpp:(.text+0x540): first defined here
collect2: error: ld returned 1 exit status