답안 #1054298

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

using namespace std;


int main()
{}

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]);
}

Compilation message

swap.cpp: In function 'void init(int, int, int*, int*, int*)':
swap.cpp:23:15: warning: variable 'M' set but not used [-Wunused-but-set-variable]
   23 |     for (auto M : mins) M = INT_MAX;
      |               ^
/usr/bin/ld: /tmp/ccku9mG3.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccHaWE31.o:swap.cpp:(.text.startup+0x0): first defined here
/usr/bin/ld: /tmp/ccku9mG3.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