Submission #1354573

#TimeUsernameProblemLanguageResultExecution timeMemory
1354573SulAXylophone (JOI18_xylophone)C++20
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define popcount __builtin_popcount
#define all(a) (a).begin(), (a).end()
using namespace std;
using namespace chrono;
using namespace __gnu_pbds;
template<typename T> using ordered_set = tree<T,null_type,less_equal<>,rb_tree_tag,tree_order_statistics_node_update>;
 
int query(int l, int r);
void answer(int i, int ai);

void solve(int n) {
    int dif[n+1];
    for (int i = 1; i < n; i++) {
        dif[i] = query(i, i+1);
    }
    int comp[n+1];
    comp[1] = 1;
    for (int i = 2; i < n; i++) {
        comp[i] = comp[i-1];
        if (dif[i-1] + dif[i] != query(i-1, i+1))
            comp[i] *= -1;
    }
    int a[n+1];
    a[1] = 1;
    for (int i = 1; i < n; i++)
        a[i+1] = a[i] + comp[i]*dif[i];
    int mn = *min_element(a+1, a+n+1);
    for (int i = 1; i <= n; i++)
        a[i] += 1 - mn;
    int p1 = find(a+1, a+n+1, 1) - a;
    int pn = find(a+1, a+n+1, n) - a;
    if (p1 > pn) {
        for (int i = 1; i <= n; i++) {
            a[i] = n+1 - a[i];
        }
    }
    for (int i = 1; i <= n; i++)
        answer(i, a[i]);
}
int a[] = { 0, 2, 1, 5, 6, 3, 4 };

int query(int l, int r) {
    int res = *max_element(a + l, a + r + 1) - *min_element(a + l, a + r + 1);
    cout<<l<<' '<<r<<' '<<res<<'\n';
    return res;
}
void answer(int i, int ai) { cout << i << " " << ai << endl; }

// int main() {
//     ios::sync_with_stdio(false);
//     cin.tie(nullptr);

//     int n; cin >> n;
//     solve(n);
// }

Compilation message (stderr)

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