제출 #1343807

#제출 시각아이디문제언어결과실행 시간메모리
1343807NewtonabcGap (APIO16_gap)C++20
컴파일 에러
0 ms0 KiB
#include "gap.h"
#include<bits/stdc++.h>
#define ll long long
using namespace std;
long long findGap(int T, int N)
{	
	if(T==2){
		vector<pair<ll,ll>> v;
		long long n=N;
		ll mn,mx;
		ll tmp=1e18;
		MinMax(1LL,tmp,&mn,&mx);
		ll l=mn,r=mx;
		long long rng=r-l;
		long long sz=(rng+n-2LL)/(n-1LL);
		for(ll i=l+sz;i<=r+sz-1;i+=sz+1LL){
			ll lb=i-sz;
			ll sec=i/sz;
			//cout<<lb <<" " <<i <<"\n";
			MinMax(lb,i,&mn,&mx);
			if(mn!=-1) v.push_back({mn,mx});
		}
		ll ans=sz;
		for(int i=0;i<(int)(v.size())-1;i++){
			ans=max(ans,v[i+1].first-v[i].second);
		}
		return ans;
	}
	else{
		long long s=-1;
       long long t=(long long)1e18+1;
       long long x=-1;
       long long y=-1;
       long long maxi=LLONG_MIN;
       for(int i=1;i<=n/2;i++){
           MinMax(s+1,t-1,&s,&t);
           v.push_back(t);
           v.push_back(s);
       }
       if(n%2==1){
        MinMax(s+1,t-1,&s,&t);
        v.push_back(s);
       }
       int i=1;
       long long xx;
       sort(v.begin(),v.end());
       for(auto a:v){
        if(i!=1){
            maxi=max(maxi,a-xx);
        }
        i++;
        xx=a;
       }
       return maxi;
	}
	return 0;
}

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

gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:35:23: error: 'n' was not declared in this scope
   35 |        for(int i=1;i<=n/2;i++){
      |                       ^
gap.cpp:37:12: error: 'v' was not declared in this scope
   37 |            v.push_back(t);
      |            ^
gap.cpp:40:11: error: 'n' was not declared in this scope
   40 |        if(n%2==1){
      |           ^
gap.cpp:42:9: error: 'v' was not declared in this scope
   42 |         v.push_back(s);
      |         ^
gap.cpp:46:13: error: 'v' was not declared in this scope
   46 |        sort(v.begin(),v.end());
      |             ^