제출 #759653

#제출 시각아이디문제언어결과실행 시간메모리
759653BulaXylophone (JOI18_xylophone)C++17
컴파일 에러
0 ms0 KiB
#include "xylophone.h" #include<bits/stdc++.h> void solve(int n){ int id1=0,l=1,r=n; while(l<=r){ int mid=(l+r)/2; int x=query(mid,n); if (x==n-1) { id1=mid; l=mid+1; }else{ r=mid-1; } } int idn=0; l=id1+1; r=n; while(l<=r){ int mid=(l+r)/2; int x=query(id1,mid); if (x==n-1) { idn=mid; r=mid-1; }else{ l=mid+1; } } vector<int> vis(n+1,0),ans(n+1,0); vis[1]=1; vis[n]=1; ans[id1]=1; ans[idn]=n; for(int i=id1-1;i>=1;i--){ int q=query(i,i+1); int a=ans[i+1]+q; int b=ans[i+1]-q; if(b<=0 || vis[b]==1){ ans[i]=a; vis[a]=1; }else if(a>n || vis[a]==1){ ans[i]=b; vis[b]=1; }else{ int x=query(i,i+2); int mx=max(a,max(ans[i+1],ans[i+2])); int mn=min(a,min(ans[i+1],ans[i+2])); if(x==mx-mn){ ans[i]=a; vis[a]=1; }else{ ans[i]=b; vis[b]=1; } } } for(int i=idn-1;i>id1;i--){ int q=query(i,i+1); int a=ans[i+1]+q; int b=ans[i+1]-q; if(b<=0 || vis[b]==1){ ans[i]=a; vis[a]=1; }else if(a>n || vis[a]==1){ ans[i]=b; vis[b]=1; }else{ int x=query(i,i+2); int mx=max(a,max(ans[i+1],ans[i+2])); int mn=min(a,min(ans[i+1],ans[i+2])); if(x==mx-mn){ ans[i]=a; vis[a]=1; }else{ ans[i]=b; vis[b]=1; } } } for(int i=idn+1;i<=n;i++){ int q=query(i,i-1); int a=ans[i-1]+q; int b=ans[i-1]-q; if(b<=0 || vis[b]==1){ ans[i]=a; vis[a]=1; }else if(a>n || vis[a]==1){ ans[i]=b; vis[b]=1; }else{ int x=query(i,i-2); int mx=max(a,max(ans[i-1],ans[i-2])); int mn=min(a,min(ans[i-1],ans[i-2])); if(x==mx-mn){ ans[i]=a; vis[a]=1; }else{ ans[i]=b; vis[b]=1; } } } for(int i=1;i<=n;i++) answer(i,ans[i]); }

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

xylophone.cpp: In function 'void solve(int)':
xylophone.cpp:32:2: error: 'vector' was not declared in this scope
   32 |  vector<int> vis(n+1,0),ans(n+1,0);
      |  ^~~~~~
xylophone.cpp:32:2: note: suggested alternatives:
In file included from /usr/include/c++/10/vector:67,
                 from /usr/include/c++/10/functional:62,
                 from /usr/include/c++/10/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/10/algorithm:74,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from xylophone.cpp:2:
/usr/include/c++/10/bits/stl_vector.h:389:11: note:   'std::vector'
  389 |     class vector : protected _Vector_base<_Tp, _Alloc>
      |           ^~~~~~
In file included from /usr/include/c++/10/functional:62,
                 from /usr/include/c++/10/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/10/algorithm:74,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from xylophone.cpp:2:
/usr/include/c++/10/vector:86:13: note:   'std::pmr::vector'
   86 |       using vector = std::vector<_Tp, polymorphic_allocator<_Tp>>;
      |             ^~~~~~
xylophone.cpp:32:9: error: expected primary-expression before 'int'
   32 |  vector<int> vis(n+1,0),ans(n+1,0);
      |         ^~~
xylophone.cpp:33:2: error: 'vis' was not declared in this scope
   33 |  vis[1]=1;
      |  ^~~
xylophone.cpp:35:2: error: 'ans' was not declared in this scope; did you mean 'abs'?
   35 |  ans[id1]=1;
      |  ^~~
      |  abs
xylophone.cpp:52:17: error: 'max' was not declared in this scope; did you mean 'std::max'?
   52 |    int mx=max(a,max(ans[i+1],ans[i+2]));
      |                 ^~~
      |                 std::max
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from xylophone.cpp:2:
/usr/include/c++/10/bits/stl_algo.h:3486:5: note: 'std::max' declared here
 3486 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
xylophone.cpp:52:11: error: 'max' was not declared in this scope; did you mean 'std::max'?
   52 |    int mx=max(a,max(ans[i+1],ans[i+2]));
      |           ^~~
      |           std::max
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from xylophone.cpp:2:
/usr/include/c++/10/bits/stl_algo.h:3486:5: note: 'std::max' declared here
 3486 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
xylophone.cpp:53:17: error: 'min' was not declared in this scope; did you mean 'std::min'?
   53 |    int mn=min(a,min(ans[i+1],ans[i+2]));
      |                 ^~~
      |                 std::min
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from xylophone.cpp:2:
/usr/include/c++/10/bits/stl_algo.h:3474:5: note: 'std::min' declared here
 3474 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
xylophone.cpp:53:11: error: 'min' was not declared in this scope; did you mean 'std::min'?
   53 |    int mn=min(a,min(ans[i+1],ans[i+2]));
      |           ^~~
      |           std::min
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from xylophone.cpp:2:
/usr/include/c++/10/bits/stl_algo.h:3474:5: note: 'std::min' declared here
 3474 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
xylophone.cpp:78:17: error: 'max' was not declared in this scope; did you mean 'std::max'?
   78 |    int mx=max(a,max(ans[i+1],ans[i+2]));
      |                 ^~~
      |                 std::max
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from xylophone.cpp:2:
/usr/include/c++/10/bits/stl_algo.h:3486:5: note: 'std::max' declared here
 3486 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
xylophone.cpp:78:11: error: 'max' was not declared in this scope; did you mean 'std::max'?
   78 |    int mx=max(a,max(ans[i+1],ans[i+2]));
      |           ^~~
      |           std::max
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from xylophone.cpp:2:
/usr/include/c++/10/bits/stl_algo.h:3486:5: note: 'std::max' declared here
 3486 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
xylophone.cpp:79:17: error: 'min' was not declared in this scope; did you mean 'std::min'?
   79 |    int mn=min(a,min(ans[i+1],ans[i+2]));
      |                 ^~~
      |                 std::min
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from xylophone.cpp:2:
/usr/include/c++/10/bits/stl_algo.h:3474:5: note: 'std::min' declared here
 3474 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
xylophone.cpp:79:11: error: 'min' was not declared in this scope; did you mean 'std::min'?
   79 |    int mn=min(a,min(ans[i+1],ans[i+2]));
      |           ^~~
      |           std::min
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from xylophone.cpp:2:
/usr/include/c++/10/bits/stl_algo.h:3474:5: note: 'std::min' declared here
 3474 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
xylophone.cpp:104:17: error: 'max' was not declared in this scope; did you mean 'std::max'?
  104 |    int mx=max(a,max(ans[i-1],ans[i-2]));
      |                 ^~~
      |                 std::max
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from xylophone.cpp:2:
/usr/include/c++/10/bits/stl_algo.h:3486:5: note: 'std::max' declared here
 3486 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
xylophone.cpp:104:11: error: 'max' was not declared in this scope; did you mean 'std::max'?
  104 |    int mx=max(a,max(ans[i-1],ans[i-2]));
      |           ^~~
      |           std::max
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from xylophone.cpp:2:
/usr/include/c++/10/bits/stl_algo.h:3486:5: note: 'std::max' declared here
 3486 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
xylophone.cpp:105:17: error: 'min' was not declared in this scope; did you mean 'std::min'?
  105 |    int mn=min(a,min(ans[i-1],ans[i-2]));
      |                 ^~~
      |                 std::min
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from xylophone.cpp:2:
/usr/include/c++/10/bits/stl_algo.h:3474:5: note: 'std::min' declared here
 3474 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
xylophone.cpp:105:11: error: 'min' was not declared in this scope; did you mean 'std::min'?
  105 |    int mn=min(a,min(ans[i-1],ans[i-2]));
      |           ^~~
      |           std::min
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from xylophone.cpp:2:
/usr/include/c++/10/bits/stl_algo.h:3474:5: note: 'std::min' declared here
 3474 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~