제출 #767952

#제출 시각아이디문제언어결과실행 시간메모리
767952MinaRagy06철로 (IOI14_rail)C++17
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h>
using namespace std;
typedef int64_t ll;

#ifdef MINA
int getDistance(int i, int j) {
    cout << i << ' ' << j << endl;
    int x;
    cin >> x;
    return x;
}
#else
int getDistance(int i, int j);
#endif
void findLocation(int n, int first, int location[], int stype[]) {
    location[0] = first, stype[0] = 1;
    if (n == 1) return;
    for (int i = 1; i < n; i++) {
        int x = getDistance(0, i), x2 = getDistance(i, 0);
        assert(x > 0), assert(x2 > 0);
        if (x2 == x) {
            location[i] = first + x;
            stype[i] = 2;
        } else {
            assert(x2 < x);
            location[i] = first - x2;
            stype[i] = 1;
        }
    }
    for (int i = 0; i < n; i++) {
        assert(location[i] > 0);
        assert(stype[i] == 1 || stype[i] == 2);
        if (stype[i] == 2) assert(location[i] > first);
        if (stype[i] == 1) assert(location[i] <= first);
    }
}
int main() {
    ios_base::sync_with_stdio(0), cin.tie(0);
    int n, first;
    cin >> n >> first;
    int location[n], stype[n];
    findLocation(n, first, location, stype);
    for (int i = 0; i < n; i++) {
        cout << location[i] << ' ' << stype[i] << '\n';
    }
    return 0;
}

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

/usr/bin/ld: /tmp/cc1NRvWV.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccIJiKuW.o:rail.cpp:(.text.startup+0x0): first defined here
/usr/bin/ld: /tmp/ccIJiKuW.o: in function `findLocation(int, int, int*, int*) [clone .part.0]':
rail.cpp:(.text+0x5f): undefined reference to `getDistance(int, int)'
/usr/bin/ld: rail.cpp:(.text+0x6a): undefined reference to `getDistance(int, int)'
/usr/bin/ld: /tmp/cc1NRvWV.o: in function `main':
grader.cpp:(.text.startup+0x2d9): undefined reference to `findLocation'
collect2: error: ld returned 1 exit status