제출 #1344870

#제출 시각아이디문제언어결과실행 시간메모리
1344870jumpGap (APIO16_gap)C++20
컴파일 에러
0 ms0 KiB
#include "gap.h"
#include <bits/stdc++.h>
#define ll long long
long long findGap(int T, int N)
{
	if(N==2){
		ll v1=0-1,v2=1e18+1;
		MinMax(v1+1,v2-1,&v1,&v2);
		return v2-v1;
	}
	if(T==1){
		std::vector<ll> vv;
		ll v1=0-1,v2=1e18+1;
		while(left.size()+right.size()<N&&v1!=v2){
			MinMax(v1+1,v2-1,&v1,&v2);
			// std::cout << v1+1 << ' ' << v2-1 << '\n';
			if(v1==-1 || v2==-1)break;
			vv.push_back(v1);
			vv.push_back(v2);
		}
		std::sort(vv.begin(),vv.end());
		int best = 0;
		for(int i=0;i<vv.size()-1;i++){
			int res = vv[i+1]-vv[i];
			best=std::max(best,res);
		}
		return best;
	}
	else{
		ll v1=0-1,v2=1e18+1,high=0,low=0;
		MinMax(v1+1,v2-1,&v1,&v2);
		high=v2;low=v1;
		ll dis = v2-v1;
		ll meandis = (dis/N) + 1;
		ll test1 =v1+1,test2 = v1+meandis;
		ll last=v1;
		ll best = 0;
		while(test1<high){
			MinMax(test1,test2,&v1,&v2);
			if(v1!=-1)
			best=std::max((ll)best,v1-last);
			if(v2!=-1)
			last=v2;
			//best=std::max(best,v2-v1);// not really needed
			test1+=meandis;
			test2+=meandis;
		}
		best=std::max(best,high-v2);
		return best;
	}
	return 0;
}

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

gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:14:23: error: 'left' was not declared in this scope; did you mean 'std::left'?
   14 |                 while(left.size()+right.size()<N&&v1!=v2){
      |                       ^~~~
      |                       std::left
In file included from /usr/include/c++/13/streambuf:43,
                 from /usr/include/c++/13/bits/streambuf_iterator.h:35,
                 from /usr/include/c++/13/iterator:66,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:54,
                 from gap.cpp:2:
/usr/include/c++/13/bits/ios_base.h:1042:3: note: 'std::left' declared here
 1042 |   left(ios_base& __base)
      |   ^~~~
gap.cpp:14:35: error: 'right' was not declared in this scope; did you mean 'std::right'?
   14 |                 while(left.size()+right.size()<N&&v1!=v2){
      |                                   ^~~~~
      |                                   std::right
/usr/include/c++/13/bits/ios_base.h:1050:3: note: 'std::right' declared here
 1050 |   right(ios_base& __base)
      |   ^~~~~