Submission #774077

# Submission time Handle Problem Language Result Execution time Memory
774077 2023-07-05T11:48:15 Z Dan4Life Xylophone (JOI18_xylophone) C++17
Compilation error
0 ms 0 KB
//#include "xylophone.h"
#include <bits/stdc++.h>
using namespace std;
int a[5010], _ok[20000];int *ok = _ok+10000;
int Query(int i, int j){return query(min(i,j),max(i,j));}
void Answer(int x, int v){answer(x,v); a[x]=v; ok[v]=1; }
 
void solve(int n) {
    int l = 1, r = n-1;
    while(l<r){
        int m = (l+r+1)/2;
        if(Query(m,n)==n-1) l=m;
        else r=m-1;
    }
    for(int i = -2*n; i <= 2*n; i++) ok[i]=(i<1 or i>n);
    Answer(l,1);
    for(int x : {1,-1}){
        for(int i = l-x; x==1?i>=1:i<=n; i-=x){
            int dif = Query(i,i+x);
            int x1 = a[i+x]-dif, x2 = a[i+x]+dif;
            if(ok[x1]) swap(x1,x2);
            if(ok[x2]) Answer(i,x1);
            else{
                int dif2 = Query(i,i+2*x);
                if(max({x1,a[i+x],a[i+2*x]})-min({x1,a[i+x],a[i+2*x]})==dif2) Answer(i,x1);
                else Answer(i,x2);
            }
        }
    }
}

Compilation message

xylophone.cpp: In function 'int Query(int, int)':
xylophone.cpp:5:32: error: 'query' was not declared in this scope; did you mean 'Query'?
    5 | int Query(int i, int j){return query(min(i,j),max(i,j));}
      |                                ^~~~~
      |                                Query
xylophone.cpp: In function 'void Answer(int, int)':
xylophone.cpp:6:27: error: 'answer' was not declared in this scope; did you mean 'Answer'?
    6 | void Answer(int x, int v){answer(x,v); a[x]=v; ok[v]=1; }
      |                           ^~~~~~
      |                           Answer