Submission #38749

# Submission time Handle Problem Language Result Execution time Memory
38749 2018-01-06T11:48:45 Z Waschbar Gap (APIO16_gap) C++14
0 / 100
39 ms 5144 KB
#include <bits/stdc++.h>
#include "gap.h"
using namespace std;

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,1ll);
			if(a1-L == 1 && a1 != -1)
				ans = max(ans,1ll);
				
			if(a3 == a4 && a4 != -1)
				ans = max(ans,R-a3);
			if(a4-a3 == 1 && a3 != -1)
				ans = max(ans,1ll);
			if(R-a4 == 1 && a4 != -1)
				ans = max(ans,1ll);
					
			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;
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 5144 KB Output isn't correct
2 Incorrect 0 ms 5144 KB Output isn't correct
3 Incorrect 0 ms 5144 KB Output isn't correct
4 Incorrect 0 ms 5144 KB Output isn't correct
5 Incorrect 0 ms 5144 KB Output isn't correct
6 Incorrect 0 ms 5144 KB Output isn't correct
7 Incorrect 0 ms 5144 KB Output isn't correct
8 Incorrect 0 ms 5144 KB Output isn't correct
9 Incorrect 0 ms 5144 KB Output isn't correct
10 Incorrect 0 ms 5144 KB Output isn't correct
11 Incorrect 0 ms 5144 KB Output isn't correct
12 Incorrect 0 ms 5144 KB Output isn't correct
13 Incorrect 0 ms 5144 KB Output isn't correct
14 Incorrect 0 ms 5144 KB Output isn't correct
15 Incorrect 0 ms 5144 KB Output isn't correct
16 Incorrect 6 ms 5144 KB Output isn't correct
17 Incorrect 9 ms 5144 KB Output isn't correct
18 Incorrect 9 ms 5144 KB Output isn't correct
19 Incorrect 0 ms 5144 KB Output isn't correct
20 Incorrect 3 ms 5144 KB Output isn't correct
21 Incorrect 33 ms 5144 KB Output isn't correct
22 Incorrect 23 ms 5144 KB Output isn't correct
23 Incorrect 36 ms 5144 KB Output isn't correct
24 Incorrect 36 ms 5144 KB Output isn't correct
25 Incorrect 23 ms 5144 KB Output isn't correct
26 Incorrect 29 ms 5144 KB Output isn't correct
27 Incorrect 39 ms 5144 KB Output isn't correct
28 Incorrect 23 ms 5144 KB Output isn't correct
29 Incorrect 23 ms 5144 KB Output isn't correct
30 Incorrect 19 ms 5144 KB Output isn't correct
31 Incorrect 0 ms 5144 KB Output isn't correct
32 Incorrect 0 ms 5144 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 5144 KB Output isn't correct
2 Incorrect 0 ms 5144 KB Output isn't correct
3 Incorrect 0 ms 5144 KB Output isn't correct
4 Incorrect 0 ms 5144 KB Output isn't correct
5 Incorrect 0 ms 5144 KB Output isn't correct
6 Incorrect 0 ms 5144 KB Output isn't correct
7 Incorrect 0 ms 5144 KB Output isn't correct
8 Incorrect 0 ms 5144 KB Output isn't correct
9 Incorrect 0 ms 5144 KB Output isn't correct
10 Incorrect 0 ms 5144 KB Output isn't correct
11 Incorrect 0 ms 5144 KB Output isn't correct
12 Incorrect 0 ms 5144 KB Output isn't correct
13 Incorrect 0 ms 5144 KB Output isn't correct
14 Incorrect 0 ms 5144 KB Output isn't correct
15 Incorrect 0 ms 5144 KB Output isn't correct
16 Incorrect 9 ms 5144 KB Output isn't correct
17 Incorrect 9 ms 5144 KB Output isn't correct
18 Incorrect 13 ms 5144 KB Output isn't correct
19 Incorrect 3 ms 5144 KB Output isn't correct
20 Incorrect 3 ms 5144 KB Output isn't correct
21 Incorrect 29 ms 5144 KB Output isn't correct
22 Incorrect 39 ms 5144 KB Output isn't correct
23 Incorrect 39 ms 5144 KB Output isn't correct
24 Incorrect 26 ms 5144 KB Output isn't correct
25 Incorrect 29 ms 5144 KB Output isn't correct
26 Incorrect 33 ms 5144 KB Output isn't correct
27 Incorrect 36 ms 5144 KB Output isn't correct
28 Incorrect 29 ms 5144 KB Output isn't correct
29 Incorrect 23 ms 5144 KB Output isn't correct
30 Incorrect 19 ms 5144 KB Output isn't correct
31 Incorrect 0 ms 5144 KB Output isn't correct
32 Incorrect 0 ms 5144 KB Output isn't correct