제출 #774077

#제출 시각아이디문제언어결과실행 시간메모리
774077Dan4LifeXylophone (JOI18_xylophone)C++17
컴파일 에러
0 ms0 KiB
//#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); } } } }

컴파일 시 표준 에러 (stderr) 메시지

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