Submission #996067

# Submission time Handle Problem Language Result Execution time Memory
996067 2024-06-10T07:43:23 Z kustizus Xylophone (JOI18_xylophone) C++17
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int N=5e3;
int a[N+5],x[N+5];
void solve(int n){
    vector <pair<int,int>> v;
    cout<<"query(1, 2)\n";
    fflush(stdout);
    int dist;
    cin>>dist;
    for (int i=3;i<=n;++i){
        cout<<"query("<<i-1<<", "<<i<<")\n";
        fflush(stdout);
        int x;
        cin>>x;
        cout<<"query("<<i-2<<", "<<i<<")\n";
        fflush(stdout);
        int y;
        cin>>y;
        v.push_back({x,y});
    }
    a[1]=1e9;
    a[2]=1e9+dist;
    x[1]=x[2]=0;
    int bruh=min(a[1],a[2]);
    for (int i=3;i<=n;++i){
        x[i]=0;
        int d=a[i-1]+v[i-3].first;
        if (max(d,max(a[i-1],a[i-2]))-min(d,min(a[i-1],a[i-2]))==v[i-3].second) a[i]=d;
        else a[i]=a[i-1]-v[i-3].first;
        bruh=min(bruh,a[i]);
    }
    --bruh;
    for (int i=1;i<=n;++i) a[i]-=bruh,x[a[i]]=i;
    bool ok=true;
    for (int i=1;i<=n;++i)
        if (!x[i]) ok=false;
    if (x[1]>x[n]) ok=false;
    if (ok){
        for (int i=1;i<=n;++i) cout<<"answer("<<i<<", "<<a[i]<<")\n";
        fflush(stdout);
        return;
    }
    a[1]=1e9;
    a[2]=1e9-dist;
    bruh=min(a[1],a[2]);
    for (int i=3;i<=n;++i){
        x[i]=0;
        int d=a[i-1]+v[i-3].first;
        if (max(d,max(a[i-1],a[i-2]))-min(d,min(a[i-1],a[i-2]))==v[i-3].second) a[i]=d;
        else a[i]=a[i-1]-v[i-3].first;
        bruh=min(bruh,a[i]);
    }
    --bruh;
    for (int i=1;i<=n;++i) a[i]-=bruh;
    for (int i=1;i<=n;++i) cout<<"answer("<<i<<", "<<a[i]<<")\n";
    fflush(stdout);
}

Compilation message

/usr/bin/ld: /tmp/ccxl3jis.o: in function `main':
grader.cpp:(.text.startup+0x30): undefined reference to `solve(int)'
collect2: error: ld returned 1 exit status