제출 #359306

#제출 시각아이디문제언어결과실행 시간메모리
359306shahriarkhanXylophone (JOI18_xylophone)C++14
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> using namespace std ; void solve(int N) { int A[N] = {0} , vis[N] = {0} , low = 1 , high = N ; while(low<high) { int mid = (low+high+1)>>1 ; if(query(mid,N)==(N-1)) low = mid ; else high = mid - 1 ; } A[low] = 1 , vis[1] = 1 ; for(int i = low - 1 ; i >= 1 ; --i) { int temp = query(i,i+1) , left = A[i+1] - temp , right = A[i+1] + temp ; if((left>0 && left<=N) && (!vis[left])) { vis[left] = 1 ; A[i] = left ; } else if((right>0 && right<=N) && (!vis[right])) { vis[right] = 1 ; A[i] = right ; } else { temp = query(i,i+2) ; if((max(left,A[i+2])-min(A[i+1],A[i+2]))==temp) { vis[left] = 1 ; A[i] = left ; } else { vis[right] = 1 ; A[i] = right ; } } } for(int i = low + 1 ; i <= N ; ++i) { int temp = query(i-1,i) , left = A[i-1] - temp , right = A[i-1] + temp ; if((left>0 && left<=N) && (!vis[left])) { vis[left] = 1 ; A[i] = left ; } else if((right>0 && right<=N) && (!vis[right])) { vis[right] = 1 ; A[i] = right ; } else { temp = query(i-2,i) ; if((max(left,A[i-2])-min(A[i-1],A[i-2]))==temp) { vis[left] = 1 ; A[i] = left ; } else { vis[right] = 1 ; A[i] = right ; } } } for(int i = 1; i <= N; i++) { answer(i, A[i]) ; } }

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

xylophone.cpp: In function 'void solve(int)':
xylophone.cpp:10:12: error: 'query' was not declared in this scope
   10 |         if(query(mid,N)==(N-1)) low = mid ;
      |            ^~~~~
xylophone.cpp:16:20: error: 'query' was not declared in this scope
   16 |         int temp = query(i,i+1) , left = A[i+1] - temp , right = A[i+1] + temp ;
      |                    ^~~~~
xylophone.cpp:17:29: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   17 |         if((left>0 && left<=N) && (!vis[left]))
      |                             ^
xylophone.cpp:17:45: error: invalid types 'int [N][std::ios_base&(std::ios_base&)]' for array subscript
   17 |         if((left>0 && left<=N) && (!vis[left]))
      |                                             ^
xylophone.cpp:19:21: error: invalid types 'int [N][std::ios_base&(std::ios_base&)]' for array subscript
   19 |             vis[left] = 1 ;
      |                     ^
xylophone.cpp:20:20: error: invalid conversion from 'std::ios_base& (*)(std::ios_base&)' to 'int' [-fpermissive]
   20 |             A[i] = left ;
      |                    ^~~~
      |                    |
      |                    std::ios_base& (*)(std::ios_base&)
xylophone.cpp:22:36: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   22 |         else if((right>0 && right<=N) && (!vis[right]))
      |                                    ^
xylophone.cpp:22:53: error: invalid types 'int [N][std::ios_base&(std::ios_base&)]' for array subscript
   22 |         else if((right>0 && right<=N) && (!vis[right]))
      |                                                     ^
xylophone.cpp:24:22: error: invalid types 'int [N][std::ios_base&(std::ios_base&)]' for array subscript
   24 |             vis[right] = 1 ;
      |                      ^
xylophone.cpp:25:20: error: invalid conversion from 'std::ios_base& (*)(std::ios_base&)' to 'int' [-fpermissive]
   25 |             A[i] = right ;
      |                    ^~~~~
      |                    |
      |                    std::ios_base& (*)(std::ios_base&)
xylophone.cpp:30:32: error: no matching function for call to 'max(std::ios_base& (&)(std::ios_base&), int&)'
   30 |             if((max(left,A[i+2])-min(A[i+1],A[i+2]))==temp)
      |                                ^
In file included from /usr/include/c++/9/bits/char_traits.h:39,
                 from /usr/include/c++/9/ios:40,
                 from /usr/include/c++/9/istream:38,
                 from /usr/include/c++/9/sstream:38,
                 from /usr/include/c++/9/complex:45,
                 from /usr/include/c++/9/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:54,
                 from xylophone.cpp:1:
/usr/include/c++/9/bits/stl_algobase.h:222:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  222 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/9/bits/stl_algobase.h:222:5: note:   template argument deduction/substitution failed:
xylophone.cpp:30:32: note:   deduced conflicting types for parameter 'const _Tp' ('std::ios_base&(std::ios_base&)' and 'int')
   30 |             if((max(left,A[i+2])-min(A[i+1],A[i+2]))==temp)
      |                                ^
In file included from /usr/include/c++/9/bits/char_traits.h:39,
                 from /usr/include/c++/9/ios:40,
                 from /usr/include/c++/9/istream:38,
                 from /usr/include/c++/9/sstream:38,
                 from /usr/include/c++/9/complex:45,
                 from /usr/include/c++/9/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:54,
                 from xylophone.cpp:1:
/usr/include/c++/9/bits/stl_algobase.h:268:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  268 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/9/bits/stl_algobase.h:268:5: note:   template argument deduction/substitution failed:
xylophone.cpp:30:32: note:   deduced conflicting types for parameter 'const _Tp' ('std::ios_base&(std::ios_base&)' and 'int')
   30 |             if((max(left,A[i+2])-min(A[i+1],A[i+2]))==temp)
      |                                ^
In file included from /usr/include/c++/9/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:65,
                 from xylophone.cpp:1:
/usr/include/c++/9/bits/stl_algo.h:3456:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)'
 3456 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/9/bits/stl_algo.h:3456:5: note:   template argument deduction/substitution failed:
xylophone.cpp:30:32: note:   mismatched types 'std::initializer_list<_Tp>' and 'std::ios_base& (*)(std::ios_base&)'
   30 |             if((max(left,A[i+2])-min(A[i+1],A[i+2]))==temp)
      |                                ^
In file included from /usr/include/c++/9/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:65,
                 from xylophone.cpp:1:
/usr/include/c++/9/bits/stl_algo.h:3462:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)'
 3462 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/9/bits/stl_algo.h:3462:5: note:   template argument deduction/substitution failed:
xylophone.cpp:30:32: note:   mismatched types 'std::initializer_list<_Tp>' and 'std::ios_base& (*)(std::ios_base&)'
   30 |             if((max(left,A[i+2])-min(A[i+1],A[i+2]))==temp)
      |                                ^
xylophone.cpp:32:25: error: invalid types 'int [N][std::ios_base&(std::ios_base&)]' for array subscript
   32 |                 vis[left] = 1 ;
      |                         ^
xylophone.cpp:33:24: error: invalid conversion from 'std::ios_base& (*)(std::ios_base&)' to 'int' [-fpermissive]
   33 |                 A[i] = left ;
      |                        ^~~~
      |                        |
      |                        std::ios_base& (*)(std::ios_base&)
xylophone.cpp:37:26: error: invalid types 'int [N][std::ios_base&(std::ios_base&)]' for array subscript
   37 |                 vis[right] = 1 ;
      |                          ^
xylophone.cpp:38:24: error: invalid conversion from 'std::ios_base& (*)(std::ios_base&)' to 'int' [-fpermissive]
   38 |                 A[i] = right ;
      |                        ^~~~~
      |                        |
      |                        std::ios_base& (*)(std::ios_base&)
xylophone.cpp:44:20: error: 'query' was not declared in this scope
   44 |         int temp = query(i-1,i) , left = A[i-1] - temp , right = A[i-1] + temp ;
      |                    ^~~~~
xylophone.cpp:45:29: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   45 |         if((left>0 && left<=N) && (!vis[left]))
      |                             ^
xylophone.cpp:45:45: error: invalid types 'int [N][std::ios_base&(std::ios_base&)]' for array subscript
   45 |         if((left>0 && left<=N) && (!vis[left]))
      |                                             ^
xylophone.cpp:47:21: error: invalid types 'int [N][std::ios_base&(std::ios_base&)]' for array subscript
   47 |             vis[left] = 1 ;
      |                     ^
xylophone.cpp:48:20: error: invalid conversion from 'std::ios_base& (*)(std::ios_base&)' to 'int' [-fpermissive]
   48 |             A[i] = left ;
      |                    ^~~~
      |                    |
      |                    std::ios_base& (*)(std::ios_base&)
xylophone.cpp:50:36: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   50 |         else if((right>0 && right<=N) && (!vis[right]))
      |                                    ^
xylophone.cpp:50:53: error: invalid types 'int [N][std::ios_base&(std::ios_base&)]' for array subscript
   50 |         else if((right>0 && right<=N) && (!vis[right]))
      |                                                     ^
xylophone.cpp:52:22: error: invalid types 'int [N][std::ios_base&(std::ios_base&)]' for array subscript
   52 |             vis[right] = 1 ;
      |                      ^
xylophone.cpp:53:20: error: invalid conversion from 'std::ios_base& (*)(std::ios_base&)' to 'int' [-fpermissive]
   53 |             A[i] = right ;
      |                    ^~~~~
      |                    |
      |                    std::ios_base& (*)(std::ios_base&)
xylophone.cpp:58:32: error: no matching function for call to 'max(std::ios_base& (&)(std::ios_base&), int&)'
   58 |             if((max(left,A[i-2])-min(A[i-1],A[i-2]))==temp)
      |                                ^
In file included from /usr/include/c++/9/bits/char_traits.h:39,
                 from /usr/include/c++/9/ios:40,
                 from /usr/include/c++/9/istream:38,
                 from /usr/include/c++/9/sstream:38,
                 from /usr/include/c++/9/complex:45,
                 from /usr/include/c++/9/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:54,
                 from xylophone.cpp:1:
/usr/include/c++/9/bits/stl_algobase.h:222:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  222 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/9/bits/stl_algobase.h:222:5: note:   template argument deduction/substitution failed:
xylophone.cpp:58:32: note:   deduced conflicting types for parameter 'const _Tp' ('std::ios_base&(std::ios_base&)' and 'int')
   58 |             if((max(left,A[i-2])-min(A[i-1],A[i-2]))==temp)
      |                                ^
In file included from /usr/include/c++/9/bits/char_traits.h:39,
                 from /usr/include/c++/9/ios:40,
                 from /usr/include/c++/9/istream:38,
                 from /usr/include/c++/9/sstream:38,
                 from /usr/include/c++/9/complex:45,
                 from /usr/include/c++/9/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:54,
                 from xylophone.cpp:1:
/usr/include/c++/9/bits/stl_algobase.h:268:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  268 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/9/bits/stl_algobase.h:268:5: note:   template argument deduction/substitution failed:
xylophone.cpp:58:32: note:   deduced conflicting types for parameter 'const _Tp' ('std::ios_base&(std::ios_base&)' and 'int')
   58 |             if((max(left,A[i-2])-min(A[i-1],A[i-2]))==temp)
      |                                ^
In file included from /usr/include/c++/9/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:65,
                 from xylophone.cpp:1:
/usr/include/c++/9/bits/stl_algo.h:3456:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)'
 3456 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/9/bits/stl_algo.h:3456:5: note:   template argument deduction/substitution failed:
xylophone.cpp:58:32: note:   mismatched types 'std::initializer_list<_Tp>' and 'std::ios_base& (*)(std::ios_base&)'
   58 |             if((max(left,A[i-2])-min(A[i-1],A[i-2]))==temp)
      |                                ^
In file included from /usr/include/c++/9/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:65,
                 from xylophone.cpp:1:
/usr/include/c++/9/bits/stl_algo.h:3462:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)'
 3462 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/9/bits/stl_algo.h:3462:5: note:   template argument deduction/substitution failed:
xylophone.cpp:58:32: note:   mismatched types 'std::initializer_list<_Tp>' and 'std::ios_base& (*)(std::ios_base&)'
   58 |             if((max(left,A[i-2])-min(A[i-1],A[i-2]))==temp)
      |                                ^
xylophone.cpp:60:25: error: invalid types 'int [N][std::ios_base&(std::ios_base&)]' for array subscript
   60 |                 vis[left] = 1 ;
      |                         ^
xylophone.cpp:61:24: error: invalid conversion from 'std::ios_base& (*)(std::ios_base&)' to 'int' [-fpermissive]
   61 |                 A[i] = left ;
      |                        ^~~~
      |                        |
      |                        std::ios_base& (*)(std::ios_base&)
xylophone.cpp:65:26: error: invalid types 'int [N][std::ios_base&(std::ios_base&)]' for array subscript
   65 |                 vis[right] = 1 ;
      |                          ^
xylophone.cpp:66:24: error: invalid conversion from 'std::ios_base& (*)(std::ios_base&)' to 'int' [-fpermissive]
   66 |                 A[i] = right ;
      |                        ^~~~~
      |                        |
      |                        std::ios_base& (*)(std::ios_base&)
xylophone.cpp:72:3: error: 'answer' was not declared in this scope
   72 |   answer(i, A[i]) ;
      |   ^~~~~~