제출 #554244

#제출 시각아이디문제언어결과실행 시간메모리
554244GurbanGap (APIO16_gap)C++17
컴파일 에러
0 ms0 KiB
#include "bits/stdc++.h"
#include "gap.h"
using namespace std;

using ll = long long;

// const int maxn=1e5+5;
// ll a[maxn];

long long findGap(int T, int N)
{
	ll cep,sag;
	if(T == 1){
		vector<int>v;
		v.push_back(cep);		
		v.push_back(sag);		
		while(cep < sag){
			ll cp,sg;
			MinMax(cep+1,sag-1,&cp,&sg);
			if(cp != -1){
				v.push_back(cp);
				if(cp == sg) break;
				v.push_back(sg);
				cep = cp;
				sag = sg;
			}
		}
		sort(v.begin(),v.end());
		ll ans = 0;
		for(int i = 1;i < (int)v.size();i++) ans = max(ans,v[i] - v[i - 1]);
		return ans;
	}
	// assert(cep != -1 && sag != -1);
	ll now = cep,ans = 1;
	while(now < sag){
		ll nwa,nwb;
		if(now + ans + 1 > sag) break;
		MinMax(now + 1,now + ans + 1,&nwa,&nwb);
		if(nwa != -1){
			ans = max(ans,nwa - now);
			now = nwb;
			
			continue;
		}
		ans++;
		while(1){
			MinMax(now + 1,now + ans * 2,&nwa,&nwb);
			if(nwa != -1){
				ans = max(nwa - now,ans);
				now = nwb;
				break;
			}
			ans *= 2;
			ans++;
		}
	}
	return ans;
}

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

gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:30:69: error: no matching function for call to 'max(ll&, __gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type)'
   30 |   for(int i = 1;i < (int)v.size();i++) ans = max(ans,v[i] - v[i - 1]);
      |                                                                     ^
In file included from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from gap.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:254:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  254 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:254:5: note:   template argument deduction/substitution failed:
gap.cpp:30:69: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'})
   30 |   for(int i = 1;i < (int)v.size();i++) ans = max(ans,v[i] - v[i - 1]);
      |                                                                     ^
In file included from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from gap.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:300:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  300 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:300:5: note:   template argument deduction/substitution failed:
gap.cpp:30:69: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'})
   30 |   for(int i = 1;i < (int)v.size();i++) ans = max(ans,v[i] - v[i - 1]);
      |                                                                     ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from gap.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3480:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)'
 3480 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3480:5: note:   template argument deduction/substitution failed:
gap.cpp:30:69: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   30 |   for(int i = 1;i < (int)v.size();i++) ans = max(ans,v[i] - v[i - 1]);
      |                                                                     ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from gap.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3486:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)'
 3486 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3486:5: note:   template argument deduction/substitution failed:
gap.cpp:30:69: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   30 |   for(int i = 1;i < (int)v.size();i++) ans = max(ans,v[i] - v[i - 1]);
      |                                                                     ^