답안 #47281

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
47281 2018-04-30T06:09:52 Z yogahmad Gap (APIO16_gap) C++14
컴파일 오류
0 ms 0 KB
long long findGap(int T, int N)
{
	if(T==1){
		long long sa,du;
		long long *kiri,*kanan;
		kiri=&sa;
		kanan=&du;
		MinMax(0,1e18,kiri,kanan);
		vector<long long>ve;
		ve.push_back(*kiri);
		long long jaw=0;
		ve.push_back(*kanan);
		while(1){
			if(*kiri>*kanan)
				break;
			MinMax(*kiri+1,*kanan-1,kiri,kanan);
			if(*kiri==-1 && *kanan==-1)
				break;
			ve.push_back(*kiri);
			ve.push_back(*kanan);
		}
		sort(ve.begin(),ve.end());
		for(int i=1;i<ve.size();i++)
			jaw=max(jaw,ve[i]-ve[i-1]);
		return jaw;
	}
//	cout<<T<<" "<<N<<endl;
	long long sa,du,ti,em;
	vector<long long>ve;
	long long *kiri,*kanan;
	kiri=&sa;
	kanan=&du;
	MinMax(0,1e18,kiri,kanan);
//	cout<<*kiri<<' '<<*kanan<<endl;
	long long gap=(*kanan-*kiri)/(N-1);
	long long jaw=0;
//	cout<<*kiri<<" "<<*kanan<<" "<<gap<<endl;
	long long awal;
	for(awal=*kiri;awal<=*kanan;awal+=gap+1){
	//	cout<<awal<<" <<<___\n";
		long long *lo,*hi;
		lo=&ti;
		hi=&em;
		MinMax(awal,awal+gap,lo,hi);
	//	cout<<awal<<' '<<awal+gap<<" -> "<<*lo<<" "<<*hi<<endl;
		if(*lo==-1 && *hi==-1)
			continue;
		ve.push_back(*lo);
		ve.push_back(*hi);
	}
//	cout<<awal<<endl;
	sort(ve.begin(),ve.end());
//	for(int i:ve)
	//	cout<<i<<' ';
//	cout<<endl;
	for(int i=1;i<ve.size();i++){
		jaw=max(jaw,ve[i]-ve[i-1]);
	}
//	cout<<jaw<<endl;
	return jaw;
}

Compilation message

gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:8:3: error: 'MinMax' was not declared in this scope
   MinMax(0,1e18,kiri,kanan);
   ^~~~~~
gap.cpp:9:3: error: 'vector' was not declared in this scope
   vector<long long>ve;
   ^~~~~~
gap.cpp:9:10: error: expected primary-expression before 'long'
   vector<long long>ve;
          ^~~~
gap.cpp:10:3: error: 've' was not declared in this scope
   ve.push_back(*kiri);
   ^~
gap.cpp:22:3: error: 'sort' was not declared in this scope
   sort(ve.begin(),ve.end());
   ^~~~
gap.cpp:22:3: note: suggested alternative: 'short'
   sort(ve.begin(),ve.end());
   ^~~~
   short
gap.cpp:24:8: error: 'max' was not declared in this scope
    jaw=max(jaw,ve[i]-ve[i-1]);
        ^~~
gap.cpp:29:2: error: 'vector' was not declared in this scope
  vector<long long>ve;
  ^~~~~~
gap.cpp:29:9: error: expected primary-expression before 'long'
  vector<long long>ve;
         ^~~~
gap.cpp:33:2: error: 'MinMax' was not declared in this scope
  MinMax(0,1e18,kiri,kanan);
  ^~~~~~
gap.cpp:48:3: error: 've' was not declared in this scope
   ve.push_back(*lo);
   ^~
gap.cpp:52:7: error: 've' was not declared in this scope
  sort(ve.begin(),ve.end());
       ^~
gap.cpp:52:2: error: 'sort' was not declared in this scope
  sort(ve.begin(),ve.end());
  ^~~~
gap.cpp:52:2: note: suggested alternative: 'short'
  sort(ve.begin(),ve.end());
  ^~~~
  short
gap.cpp:57:7: error: 'max' was not declared in this scope
   jaw=max(jaw,ve[i]-ve[i-1]);
       ^~~