제출 #540434

#제출 시각아이디문제언어결과실행 시간메모리
540434krit3379Xylophone (JOI18_xylophone)C++17
컴파일 에러
0 ms0 KiB
#include<bits/stdc++.h> using namespace std; #define N 5005 int a[N],b[N],ans[N]; void solve(int n){ int i,mi=0,ma=0,pmi=1,pma=1; for(i=1;i<n;i++){ a[i]=query(i,i+1); if(i!=n-1)b[i]=query(i,i+2); } for(i=1;i<n-1;i++){ if(b[i]!=abs(a[i])+a[i+1]&&a[i]>0)a[i+1]*=-1; else if(b[i]==abs(a[i])+a[i+1]&&a[i]<0)a[i+1]*=-1; } ans[1]=0; for(i=1;i<n;i++){ ans[i+1]+=ans[i]+a[i]; if(ans[i+1]<mi)mi=ans[i+1],pmi=i+1; if(ans[i+1]>ma)ma=ans[i+1],pma=i+1; } for(i=1;i<=n;i++)ans[i]-=mi-1; if(pmi<pma)for(i=1;i<=n;i++)answer(i,ans[i]); else for(i=1;i<=n;i++)answer(i,n-ans[i]+1); return ; }

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

xylophone.cpp: In function 'void solve(int)':
xylophone.cpp:10:14: error: 'query' was not declared in this scope
   10 |         a[i]=query(i,i+1);
      |              ^~~~~
xylophone.cpp:24:33: error: 'answer' was not declared in this scope
   24 |     if(pmi<pma)for(i=1;i<=n;i++)answer(i,ans[i]);
      |                                 ^~~~~~
xylophone.cpp:25:27: error: 'answer' was not declared in this scope
   25 |     else for(i=1;i<=n;i++)answer(i,n-ans[i]+1);
      |                           ^~~~~~