Submission #38746

# Submission time Handle Problem Language Result Execution time Memory
38746 2018-01-06T11:46:46 Z Waschbar Gap (APIO16_gap) C++14
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
#include "gap.h"

const long long INF = 1e18;

long long findGap(int T, int N) {
	
	multiset < pair< long long,pair<long long,long long> > > st;
	long long mn, mx;
	MinMax(0,INF,&mn,&mx);
	
	st.insert({-(mx-mx),{mn,mx}});
	long long ans = 0;
	
	while(!st.empty()) {
		long long L, R;
		if(abs(st.begin()->first) <= ans)
			return ans;
		L = st.begin()->second.first;
		R = st.begin()->second.second;
		long long a1, a2, a3, a4;
		
			MinMax(L,(L+R)/2,&a1,&a2);
			MinMax((L+R)/2+1,R,&a3,&a4);
			
			if(a1 == a2 && a1 != -1)
				ans = max(ans,a2-L);
			if(a2-a1 == 1 && a1 != -1)
				ans = max(ans,1);
			if(a1-L == 1 && a1 != -1)
				ans = max(ans,1);
				
			if(a3 == a4 && a4 != -1)
				ans = max(ans,R-a3);
			if(a4-a3 == 1 && a3 != -1)
				ans = max(ans,1);
			if(R-a4 == 1 && a4 != -1)
				ans = max(ans,1);
					
			if(a2 != -1 && a3 != -1)
				ans = max(ans,a3-a2);
			if(a3 == -1 && a1 == -1)
				ans = max(ans,R-L);
			if(a1 == -1 && a3 != -1)
				ans = max(ans,a3-L);
			if(a3 == -1 && a2 != -1)
				ans = max(ans,R-a2);
			
			if(a1 != -1 && a1-L > 1)
				st.insert({L-a1,{L,a1}});
			if(a1 != -1 && a2-a1 > 1)
				st.insert({a1-a2,{a1,a2}});
			if(a1 != -1 &&  a3 != -1 && a3-a2 > 1)
				st.insert({a2-a3,{a2,a3}});
			if(a3 != -1 && a4-a3 > 1)
				st.insert({a3-a4,{a3,a4}});
			if(a3 != -1 && R-a4 > 1)
				st.insert({a4-R,{a4,R}});
	}
	
	return ans;
	
	return 0;
}

Compilation message

gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:8:2: error: 'multiset' was not declared in this scope
  multiset < pair< long long,pair<long long,long long> > > st;
  ^
gap.cpp:8:2: note: suggested alternative:
In file included from /usr/include/c++/5/set:62:0,
                 from /usr/include/x86_64-linux-gnu/c++/5/bits/stdc++.h:86,
                 from gap.cpp:1:
/usr/include/c++/5/bits/stl_multiset.h:92:11: note:   'std::multiset'
     class multiset
           ^
gap.cpp:8:13: error: 'pair' was not declared in this scope
  multiset < pair< long long,pair<long long,long long> > > st;
             ^
gap.cpp:8:13: note: suggested alternative:
In file included from /usr/include/c++/5/bits/stl_algobase.h:64:0,
                 from /usr/include/c++/5/bits/char_traits.h:39,
                 from /usr/include/c++/5/ios:40,
                 from /usr/include/c++/5/istream:38,
                 from /usr/include/c++/5/sstream:38,
                 from /usr/include/c++/5/complex:45,
                 from /usr/include/c++/5/ccomplex:38,
                 from /usr/include/x86_64-linux-gnu/c++/5/bits/stdc++.h:52,
                 from gap.cpp:1:
/usr/include/c++/5/bits/stl_pair.h:96:12: note:   'std::pair'
     struct pair
            ^
gap.cpp:8:19: error: expected primary-expression before 'long'
  multiset < pair< long long,pair<long long,long long> > > st;
                   ^
gap.cpp:12:2: error: 'st' was not declared in this scope
  st.insert({-(mx-mx),{mn,mx}});
  ^
gap.cpp:27:23: error: 'max' was not declared in this scope
     ans = max(ans,a2-L);
                       ^
gap.cpp:27:23: note: suggested alternative:
In file included from /usr/include/c++/5/algorithm:62:0,
                 from /usr/include/x86_64-linux-gnu/c++/5/bits/stdc++.h:64,
                 from gap.cpp:1:
/usr/include/c++/5/bits/stl_algo.h:3463:5: note:   'std::max'
     max(initializer_list<_Tp> __l, _Compare __comp)
     ^
gap.cpp:29:20: error: 'max' was not declared in this scope
     ans = max(ans,1);
                    ^
gap.cpp:29:20: note: suggested alternative:
In file included from /usr/include/c++/5/algorithm:62:0,
                 from /usr/include/x86_64-linux-gnu/c++/5/bits/stdc++.h:64,
                 from gap.cpp:1:
/usr/include/c++/5/bits/stl_algo.h:3463:5: note:   'std::max'
     max(initializer_list<_Tp> __l, _Compare __comp)
     ^
gap.cpp:31:20: error: 'max' was not declared in this scope
     ans = max(ans,1);
                    ^
gap.cpp:31:20: note: suggested alternative:
In file included from /usr/include/c++/5/algorithm:62:0,
                 from /usr/include/x86_64-linux-gnu/c++/5/bits/stdc++.h:64,
                 from gap.cpp:1:
/usr/include/c++/5/bits/stl_algo.h:3463:5: note:   'std::max'
     max(initializer_list<_Tp> __l, _Compare __comp)
     ^
gap.cpp:34:23: error: 'max' was not declared in this scope
     ans = max(ans,R-a3);
                       ^
gap.cpp:34:23: note: suggested alternative:
In file included from /usr/include/c++/5/algorithm:62:0,
                 from /usr/include/x86_64-linux-gnu/c++/5/bits/stdc++.h:64,
                 from gap.cpp:1:
/usr/include/c++/5/bits/stl_algo.h:3463:5: note:   'std::max'
     max(initializer_list<_Tp> __l, _Compare __comp)
     ^
gap.cpp:36:20: error: 'max' was not declared in this scope
     ans = max(ans,1);
                    ^
gap.cpp:36:20: note: suggested alternative:
In file included from /usr/include/c++/5/algorithm:62:0,
                 from /usr/include/x86_64-linux-gnu/c++/5/bits/stdc++.h:64,
                 from gap.cpp:1:
/usr/include/c++/5/bits/stl_algo.h:3463:5: note:   'std::max'
     max(initializer_list<_Tp> __l, _Compare __comp)
     ^
gap.cpp:38:20: error: 'max' was not declared in this scope
     ans = max(ans,1);
                    ^
gap.cpp:38:20: note: suggested alternative:
In file included from /usr/include/c++/5/algorithm:62:0,
                 from /usr/include/x86_64-linux-gnu/c++/5/bits/stdc++.h:64,
                 from gap.cpp:1:
/usr/include/c++/5/bits/stl_algo.h:3463:5: note:   'std::max'
     max(initializer_list<_Tp> __l, _Compare __comp)
     ^
gap.cpp:41:24: error: 'max' was not declared in this scope
     ans = max(ans,a3-a2);
                        ^
gap.cpp:41:24: note: suggested alternative:
In file included from /usr/include/c++/5/algorithm:62:0,
                 from /usr/include/x86_64-linux-gnu/c++/5/bits/stdc++.h:64,
                 from gap.cpp:1:
/usr/include/c++/5/bits/stl_algo.h:3463:5: note:   'std::max'
     max(initializer_list<_Tp> __l, _Compare __comp)
     ^
gap.cpp:43:22: error: 'max' was not declared in this scope
     ans = max(ans,R-L);
                      ^
gap.cpp:43:22: note: suggested alternative:
In file included from /usr/include/c++/5/algorithm:62:0,
                 from /usr/include/x86_64-linux-gnu/c++/5/bits/stdc++.h:64,
                 from gap.cpp:1:
/usr/include/c++/5/bits/stl_algo.h:3463:5: note:   'std::max'
     max(initializer_list<_Tp> __l, _Compare __comp)
     ^
gap.cpp:45:23: error: 'max' was not declared in this scope
     ans = max(ans,a3-L);
                       ^
gap.cpp:45:23: note: suggested alternative:
In file included from /usr/include/c++/5/algorithm:62:0,
                 from /usr/include/x86_64-linux-gnu/c++/5/bits/stdc++.h:64,
                 from gap.cpp:1:
/usr/include/c++/5/bits/stl_algo.h:3463:5: note:   'std::max'
     max(initializer_list<_Tp> __l, _Compare __comp)
     ^
gap.cpp:47:23: error: 'max' was not declared in this scope
     ans = max(ans,R-a2);
                       ^
gap.cpp:47:23: note: suggested alternative:
In file included from /usr/include/c++/5/algorithm:62:0,
                 from /usr/include/x86_64-linux-gnu/c++/5/bits/stdc++.h:64,
                 from gap.cpp:1:
/usr/include/c++/5/bits/stl_algo.h:3463:5: note:   'std::max'
     max(initializer_list<_Tp> __l, _Compare __comp)
     ^