답안 #64594

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
64594 2018-08-05T02:42:35 Z nvmdava 커다란 상품 (IOI17_prize) C++17
컴파일 오류
0 ms 0 KB
#include "prize.h"
#include <bits/stdc++.h>
using namespace std;
 
 
vector<int> ans[210000];
int mx = -1, ll, rr, Q = -1;
int find(int l, int r, bool q){
	if(Q != -1){
		return 0;
	}
	if(ans[l][0] == ans[r][0]){
		return 0;
	}
	if(ll > r || rr < l){
		return 0;
	}
	int m = (l + r) >> 1, L = m, R = m + 1;
	while(l < L){
		if(L < ll){
			break;
		}
		ans[L] =ask(L);
		if(ans[L][0] + ans[L][1] == mx){
			break;
		}
		if(ans[L][0] + ans[L][1] == 0){
			Q = L;
			return L;
		}
		if(ans[L][0] == 0){
			ll = L + 1;
			break;
		}
		L--;
	}
	while(r > R){
		if(R > rr){
			break;
		}
		ans[R] =ask(R);
		if(ans[R][0] + ans[R][1] == mx){
			break;
		}
		if(ans[R][0] + ans[R][1] == 0){
			Q = R;
			return R;
		}
		if(ans[R][1] == 0){
			rr = R - 1;
			break;	
		}
		R++;
	}
	if(q == 1){
		return max(find(l, L, 0), find(R, r, 0))
	}
	return max(find(l, L, 1), find(R, r, 1));
}
 
int find_best(int n) {
	ll = 0;
	rr = n - 1;
	for(int i = 0; i < 448; i++){
		ans[i] = ask(i);
		if(ans[i][0] + ans[i][1] == 0){
			return i;
		}
		mx = max(mx, ans[i][0] + ans[i][1]);
	}
	int l = 0, r = n - 1;
	while(true){
		if(ans[l][0] + ans[l][1] == mx){
			break;
		}
		l++;
	}
	while(true){
		
		ans[r] = ask(r);
		
		if(ans[r][0] + ans[r][1] == mx){
			break;
		}
		if(ans[r][0] + ans[r][1] == 0){
			return r;
		}
		r--;
	}
	return find(l, r);
}

Compilation message

prize.cpp: In function 'int find(int, int, bool)':
prize.cpp:57:2: error: expected ';' before '}' token
  }
  ^
prize.cpp: In function 'int find_best(int)':
prize.cpp:90:18: error: no matching function for call to 'find(int&, int&)'
  return find(l, r);
                  ^
prize.cpp:8:5: note: candidate: int find(int, int, bool)
 int find(int l, int r, bool q){
     ^~~~
prize.cpp:8:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/7/algorithm:62:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:65,
                 from prize.cpp:2:
/usr/include/c++/7/bits/stl_algo.h:3899:5: note: candidate: template<class _IIter, class _Tp> _IIter std::find(_IIter, _IIter, const _Tp&)
     find(_InputIterator __first, _InputIterator __last,
     ^~~~
/usr/include/c++/7/bits/stl_algo.h:3899:5: note:   template argument deduction/substitution failed:
prize.cpp:90:18: note:   candidate expects 3 arguments, 2 provided
  return find(l, r);
                  ^
In file included from /usr/include/c++/7/bits/locale_facets.h:48:0,
                 from /usr/include/c++/7/bits/basic_ios.h:37,
                 from /usr/include/c++/7/ios:44,
                 from /usr/include/c++/7/istream:38,
                 from /usr/include/c++/7/sstream:38,
                 from /usr/include/c++/7/complex:45,
                 from /usr/include/c++/7/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52,
                 from prize.cpp:2:
/usr/include/c++/7/bits/streambuf_iterator.h:369:5: note: candidate: template<class _CharT2> typename __gnu_cxx::__enable_if<std::__is_char<_CharT2>::__value, std::istreambuf_iterator<_CharT> >::__type std::find(std::istreambuf_iterator<_CharT>, std::istreambuf_iterator<_CharT>, const _CharT2&)
     find(istreambuf_iterator<_CharT> __first,
     ^~~~
/usr/include/c++/7/bits/streambuf_iterator.h:369:5: note:   template argument deduction/substitution failed:
prize.cpp:90:18: note:   mismatched types 'std::istreambuf_iterator<_CharT>' and 'int'
  return find(l, r);
                  ^
In file included from /usr/include/c++/7/algorithm:62:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:65,
                 from prize.cpp:2:
/usr/include/c++/7/bits/stl_algo.h: In instantiation of '_Iterator std::__find_if(_Iterator, _Iterator, _Predicate) [with _Iterator = int; _Predicate = __gnu_cxx::__ops::_Iter_equals_val<const int>]':
/usr/include/c++/7/bits/stl_algo.h:3907:28:   required from '_IIter std::find(_IIter, _IIter, const _Tp&) [with _IIter = int; _Tp = int]'
prize.cpp:56:26:   required from here
/usr/include/c++/7/bits/stl_algo.h:162:34: error: no matching function for call to '__iterator_category(int&)'
          std::__iterator_category(__first));
          ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~
In file included from /usr/include/c++/7/bits/stl_algobase.h:65:0,
                 from /usr/include/c++/7/vector:60,
                 from prize.h:1,
                 from prize.cpp:1:
/usr/include/c++/7/bits/stl_iterator_base_types.h:205:5: note: candidate: template<class _Iter> constexpr typename std::iterator_traits<_Iterator>::iterator_category std::__iterator_category(const _Iter&)
     __iterator_category(const _Iter&)
     ^~~~~~~~~~~~~~~~~~~
/usr/include/c++/7/bits/stl_iterator_base_types.h:205:5: note:   template argument deduction/substitution failed:
/usr/include/c++/7/bits/stl_iterator_base_types.h: In substitution of 'template<class _Iter> constexpr typename std::iterator_traits<_Iterator>::iterator_category std::__iterator_category(const _Iter&) [with _Iter = int]':
/usr/include/c++/7/bits/stl_algo.h:162:34:   required from '_Iterator std::__find_if(_Iterator, _Iterator, _Predicate) [with _Iterator = int; _Predicate = __gnu_cxx::__ops::_Iter_equals_val<const int>]'
/usr/include/c++/7/bits/stl_algo.h:3907:28:   required from '_IIter std::find(_IIter, _IIter, const _Tp&) [with _IIter = int; _Tp = int]'
prize.cpp:56:26:   required from here
/usr/include/c++/7/bits/stl_iterator_base_types.h:205:5: error: no type named 'iterator_category' in 'struct std::iterator_traits<int>'