Submission #918976

# Submission time Handle Problem Language Result Execution time Memory
918976 2024-01-31T02:06:27 Z viwlesxq Xylophone (JOI18_xylophone) C++17
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;
//#define int long long
#include "grader.cpp"

void solve(int n) {
    vector<int> a(n + 1), d(n + 1);
    for (int i = 1; i < n; ++i) {
        d[i] = query(i, i + 1);
    }
    int min = 1, hi = n;
    while (min + 1 < hi) {
        int mid = (min + hi) / 2;
        if ((mid + 1 < n ? query(mid, n) : d[mid]) == n - 1) min = mid;
        else hi = mid;
    }
    a[min] = 1;
    int last = min, sum = 0;
    bool increasing = true;
    for (int i = min - 1; i > 0; --i) {
        int diff = query(i, last), add = d[i];
        if (sum + add != diff) {
            last = i + 1, sum = 0;
            increasing ^= true;
        }
        a[i] = a[i + 1] + (increasing ? add : -add);
        sum += add;
    }
    last = min, sum = 0;
    increasing = true;
    for (int i = min + 1; i <= n; ++i) {
        int diff = query(last, i), add = d[i - 1];
        if (sum + add != diff) {
            last = i - 1, sum = 0;
            increasing ^= true;
        }
        a[i] = a[i - 1] + (increasing ? add : -add);
        sum += add;
    }
    for (int i = 1; i <= n; ++i) {
        answer(i, a[i]);
    }
}

Compilation message

/usr/bin/ld: /tmp/ccvLLvVk.o: in function `query(int, int)':
grader.cpp:(.text+0x0): multiple definition of `query(int, int)'; /tmp/cchko4Cm.o:xylophone.cpp:(.text+0x0): first defined here
/usr/bin/ld: /tmp/ccvLLvVk.o: in function `answer(int, int)':
grader.cpp:(.text+0xa0): multiple definition of `answer(int, int)'; /tmp/cchko4Cm.o:xylophone.cpp:(.text+0xa0): first defined here
/usr/bin/ld: /tmp/ccvLLvVk.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/cchko4Cm.o:xylophone.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status