제출 #1348206

#제출 시각아이디문제언어결과실행 시간메모리
1348206jumpGap (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(T==1){
		ll mn,mx,ans = 0;
    	MinMax(0,1e18,&mn,&mx);
		std::vector<ll> left={mn};
		std::vector<ll> right={mx};
		ll l=1,r=N-2;
		while(l<=r){
			MinMax(mn+1,mx-1,&mn,&mx);
			// std::cout << v1+1 << ' ' << v2-1 << '\n';
			if(v1==-1 || v2==-1)break;
			left.push_back(mn);
			right.push_back(mx);
			l+=1;r-=1;
		}
		ll best=0;
		for(int i=0;i<left.size()-1;i++){
			ll diff = left[i+1]-left[i];
			best=std::max(diff,best);
		}
		for(int i=0;i<right.size()-1;i++){
			ll diff = right[i]-right[i+1];
			best=std::max(diff,best);
		}
		best=std::max(best,right.back()-left.back());
		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:15:28: error: 'v1' was not declared in this scope; did you mean '__pstl::execution::v1'?
   15 |                         if(v1==-1 || v2==-1)break;
      |                            ^~
      |                            __pstl::execution::v1
In file included from /usr/include/c++/13/pstl/glue_algorithm_defs.h:15,
                 from /usr/include/c++/13/algorithm:73,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:51,
                 from gap.cpp:2:
/usr/include/c++/13/pstl/execution_defs.h:19:18: note: '__pstl::execution::v1' declared here
   19 | inline namespace v1
      |                  ^~
gap.cpp:15:38: error: 'v2' was not declared in this scope
   15 |                         if(v1==-1 || v2==-1)break;
      |                                      ^~