제출 #152722

#제출 시각아이디문제언어결과실행 시간메모리
152722junodeveloperXylophone (JOI18_xylophone)C++14
컴파일 에러
0 ms0 KiB
#include "xylophone.h" static int A[5010]; static bool used[5010]; inline void Set(int i, int x) { A[i]=x; used[x]=1; } inline bool Poss(int x) { return 1<=x&&x<=N&&!used[x]; } void solve(int N) { int lo=1, hi=n, x, y; while(lo<hi) { int mid=(lo+hi+1)/2; x=query(mid,N); if(x==N-1) lo=mid; else hi=mid-1; } Set(lo,1); int i; if(lo+1<=n) { x=query(lo,lo+1); Set(lo+1,x+1); } if(lo-1>=1) { x=query(lo-1,lo); Set(lo-1,x+1); } for(i=lo+2;i<=N;i++) { x=query(i-1,i); if(!Poss(A[i-1]+x)) { Set(i,A[i-1]-x); } else if(!Poss(A[i-1]-x)) { Set(i,A[i-1]+x); } else { if(A[i-2]>A[i-1]) { y=query(i-2,i); if(y==A[i-2]-A[i-1]+x) { Set(i,A[i-1]-x); } else { Set(i,A[i-1]+x); } } } } for(i=lo-2;i>=1;i--) { x=query(i,i+1); if(!Poss(A[i+1]+x)) { Set(i,A[i+1]-x); } else if(!Poss(A[i+1]-x)) { Set(i,A[i+1]+x); } else { if(A[i+2]>A[i+1]) { y=query(i,i+2); if(y==A[i+2]-A[i+1]+x) { Set(i,A[i+1]-x); } else { Set(i,A[i+1]+x); } } } } for(i=1;i<=N;i++) answer(i,i); }

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

xylophone.cpp: In function 'bool Poss(int)':
xylophone.cpp:10:18: error: 'N' was not declared in this scope
  return 1<=x&&x<=N&&!used[x];
                  ^
xylophone.cpp: In function 'void solve(int)':
xylophone.cpp:13:15: error: 'n' was not declared in this scope
  int lo=1, hi=n, x, y;
               ^
xylophone.cpp:16:3: error: 'x' was not declared in this scope
   x=query(mid,N);
   ^
xylophone.cpp:23:3: error: 'x' was not declared in this scope
   x=query(lo,lo+1);
   ^
xylophone.cpp:27:3: error: 'x' was not declared in this scope
   x=query(lo-1,lo);
   ^
xylophone.cpp:31:3: error: 'x' was not declared in this scope
   x=query(i-1,i);
   ^
xylophone.cpp:38:5: error: 'y' was not declared in this scope
     y=query(i-2,i);
     ^
xylophone.cpp:48:3: error: 'x' was not declared in this scope
   x=query(i,i+1);
   ^
xylophone.cpp:55:5: error: 'y' was not declared in this scope
     y=query(i,i+2);
     ^