답안 #1054291

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1054291 2024-08-12T08:26:57 Z kiryl_krutsko 자매 도시 (APIO20_swap) C++14
컴파일 오류
0 ms 0 KB
#include <iostream>
#include <climits>
#include <vector>

using namespace std;

struct Min {
    int value = -1;
    int num;
    Min(int v, int n) {
        value = v; num = n;
    }
};

bool isTree;
vector<int> mins(3);
vector<int> gas;


void init(int n, int m, int e1[], int e2[], int g[]) {
    if (m != n - 1 || m == 2) {
        isTree = false;
        return;
    }
    isTree = true;
    for (auto M : mins) M = INT_MAX;
    for (int i = 0; i < m;i++) {
        gas.push_back(g[i]);
        if (g[i] < mins[0]) {
            mins.insert(mins.begin(), g[i]);
            mins.erase(mins.begin() + 3);
        }
        else if (g[i] < mins[1]) {
            mins.insert(mins.begin() + 1, g[i]);
            mins.erase(mins.begin() + 3);
        }
        else if (g[i] < mins[2]) {
            mins.insert(mins.begin() + 2, g[i]);
            mins.erase(mins.begin() + 3);
        }
    }
}

int getMinimumFuelCapacity(int x, int y) {
    if (!isTree) return -1;
    if (x == 0 || y == 0) {
        y = max(x, y);
        x = 0;
        if (gas[y] == mins[0]) return mins[1];
        else return gas[y];
    }
    if (gas[x] + gas[y] == mins[0] + mins[1]) {
        return mins[2];
    }
    else return max(gas[x], gas[y]);
}

int main()
{}

Compilation message

swap.cpp: In function 'void init(int, int, int*, int*, int*)':
swap.cpp:27:15: warning: variable 'M' set but not used [-Wunused-but-set-variable]
   27 |     for (auto M : mins) M = INT_MAX;
      |               ^
/usr/bin/ld: /tmp/cc5JhtMM.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/cczTSrvM.o:swap.cpp:(.text.startup+0x0): first defined here
/usr/bin/ld: /tmp/cc5JhtMM.o: in function `main':
grader.cpp:(.text.startup+0x1c3): undefined reference to `init(int, int, std::vector<int, std::allocator<int> >, std::vector<int, std::allocator<int> >, std::vector<int, std::allocator<int> >)'
collect2: error: ld returned 1 exit status