제출 #590493

#제출 시각아이디문제언어결과실행 시간메모리
590493karriganXylophone (JOI18_xylophone)C++14
컴파일 에러
0 ms0 KiB
#include<bits/stdc++.h> #define fastio ios_base::sync_with_stdio(false);cin.tie(nullptr); using namespace std; int a[5009]; int pos[5009]; void solve(int n){ for (int i=1;i<=n;i++){ cin>>a[i]; pos[i]=0; } int l=1,r=n; int pos1=1; while (l<=r){ int mid=(l+r)/2; int d=query(mid,n); if (d==n-1){ l=mid+1; pos1=mid; } else { r=mid-1; } } a[pos1]=1; pos[1]=1; a[pos1+1]=query(pos1,pos1+1)+1; pos[a[pos1+1]]=1; if (pos1>1){ a[pos1-1]=query(pos1-1,pos1)+1; pos[a[pos1-1]]=1; } for (int i=pos1+2;i<=n;i++){ int d=query(i-1,i); if (a[i-1]+d>n){ a[i]=a[i-1]-d; } else if (a[i-1]-d<0){ a[i]=a[i-1]+d; } if (a[i-1]+d<=n&&a[i-1]-d>0){ if (pos[a[i-1]+d]==1){ a[i]=a[i-1]-d; } else if (pos[a[i-1]-d]==1){ a[i]=a[i-1]+d; } else if (pos[a[i-1]-d]==0&&pos[a[i-1]+d]==0){ int rr=query(i-2,i); int l1=a[i-1]-d,l2=a[i-1]+d; if (max(l1,a[i-1],a[i-2])-min(l1,a[i-1],a[i-2])==rr){ a[i]=a[i-1]-d; } else { a[i]=a[i-1]+d; } } } pos[a[i]]=1; } for (int i=pos1-2;i>=1;i--){ int d=query(i,i+1); if (a[i+1]+d>n){ a[i]=a[i+1]-d; } else if (a[i+1]-d<0){ a[i]=a[i+1]+d; } if (a[i+1]+d<=n&&a[i+1]-d>0){ if (pos[a[i+1]+d]==1){ a[i]=a[i+1]-d; } else if (pos[a[i+1]-d]==1){ a[i]=a[i+1]+d; } else if (pos[a[i+1]-d]==0&&pos[a[i+1]+d]==0){ int rr=query(i+2,i); int l1=a[i+1]-d,l2=a[i+1]+d; if (max(l1,a[i+1],a[i+2])-min(l1,a[i+1],a[i+2])==rr){ a[i]=a[i+1]-d; } else { a[i]=a[i+1]+d; } } } pos[a[i]]=1; } } /*int main() { fastio //freopen(".INP","r",stdin); //freopen(".OUT","w",stdout); }*/

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

xylophone.cpp: In function 'void solve(int)':
xylophone.cpp:15:11: error: 'query' was not declared in this scope
   15 |     int d=query(mid,n);
      |           ^~~~~
xylophone.cpp:26:11: error: 'query' was not declared in this scope
   26 | a[pos1+1]=query(pos1,pos1+1)+1;
      |           ^~~~~
xylophone.cpp:49:33: warning: unused variable 'l2' [-Wunused-variable]
   49 |                 int l1=a[i-1]-d,l2=a[i-1]+d;
      |                                 ^~
xylophone.cpp:77:33: warning: unused variable 'l2' [-Wunused-variable]
   77 |                 int l1=a[i+1]-d,l2=a[i+1]+d;
      |                                 ^~
In file included from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/ios:40,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from xylophone.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h: In instantiation of 'constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare) [with _Tp = int; _Compare = int]':
xylophone.cpp:50:41:   required from here
/usr/include/c++/10/bits/stl_algobase.h:303:17: error: '__comp' cannot be used as a function
  303 |       if (__comp(__a, __b))
      |           ~~~~~~^~~~~~~~~~
/usr/include/c++/10/bits/stl_algobase.h: In instantiation of 'constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare) [with _Tp = int; _Compare = int]':
xylophone.cpp:50:63:   required from here
/usr/include/c++/10/bits/stl_algobase.h:281:17: error: '__comp' cannot be used as a function
  281 |       if (__comp(__b, __a))
      |           ~~~~~~^~~~~~~~~~