Submission #676501

#TimeUsernameProblemLanguageResultExecution timeMemory
676501yellowtoadXylophone (JOI18_xylophone)C++17
Compilation error
0 ms0 KiB
#include <iostream>
using namespace std;

int main() {
    int n, ans[10010], a[5010], b[5010], ax, ay, bx, by;
    bool add;
    cin >> n;
    for (int i = 1; i < n; i++) {
        cout << "Q " << i << " " << i+1 << endl;
        cin >> ans[i];
        if (i != n-1) {
            cout << "Q " << i << " " << i+2 << endl;
            cin >> ans[n+i];
        }
    }
    a[1] = b[1] = 0;
    add = 1;
    a[2] = a[1]+ans[1];
    b[2] = b[1]-ans[1];
    for (int i = 3; i <= n; i++) {
        if ((ans[i-2] == ans[i-2+n]) || (ans[i-1] == ans[i-2+n])) {
            if (add) {
                a[i] = a[i-1]-ans[i-1];
                b[i] = b[i-1]+ans[i-1];
                add = 0;
            } else {
                a[i] = a[i-1]+ans[i-1];
                b[i] = b[i-1]-ans[i-1];
                add = 1;
            }
        } else {
            if (add) {
                a[i] = a[i-1]+ans[i-1];
                b[i] = b[i-1]-ans[i-1];
            } else {
                a[i] = a[i-1]-ans[i-1];
                b[i] = b[i-1]+ans[i-1];
            }
        }
    }
    ax = ay = bx = by = 1;
    for (int i = 2; i <= n; i++) {
        if (a[ax] > a[i]) ax = i;
        if (a[ay] < a[i]) ay = i;
        if (b[bx] > b[i]) bx = i;
        if (b[by] < b[i]) by = i;
    }
    if (ax < ay) {
        cout << "A";
        for (int i = 1; i <= n; i++) cout << " " << a[i]+(1-a[ax]);
        cout << endl;
    } else {
        cout << "A";
        for (int i = 1; i <= n; i++) cout << " " << b[i]+(1-b[bx]);
        cout << endl;
    }
}

Compilation message (stderr)

/usr/bin/ld: /tmp/ccq6ou07.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/cczbqq49.o:xylophone.cpp:(.text.startup+0x0): first defined here
/usr/bin/ld: /tmp/ccq6ou07.o: in function `main':
grader.cpp:(.text.startup+0x30): undefined reference to `solve(int)'
collect2: error: ld returned 1 exit status