Submission #709294

#TimeUsernameProblemLanguageResultExecution timeMemory
709294WonderfulWhaleGap (APIO16_gap)C++17
64.88 / 100
45 ms2668 KiB
#include<bits/stdc++.h>
#include"gap.h"
using namespace std;

#define int long long
#define pb push_back
#define st first
#define nd second
#define pii pair<int, int>
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()

long long findGap(int32_t t, int32_t n) {
	if(t==1 || n<=10) {
		vector<int> a;
		vector<int> b;
		int l = 0;
		int r = 1e18;
		for(int i=0;i<(n+1)/2;i++) {
			int x, y;
			MinMax(l, r, &x, &y);
			a.pb(x);
			b.pb(y);
			l = x+1;
			r = y-1;
		}
		reverse(all(b));
		for(int x:b) a.pb(x);
		int ans = 0;
		for(int i=0;i<sz(a)-1;i++) {
			ans = max(ans, a[i+1]-a[i]);
		}
		return ans;
	}
	int l, r;
	MinMax(0, 1e18, &l, &r);
	int cur = l;
	int jump = 1;
	int ans = 0;
	int S = 1;
	while(cur!=r) {
		int x, y;
		MinMax(cur+1, cur+S, &x, &y);
		if(x!=-1) {
			ans = max(ans, x-cur);
			cur = y;
			S = 0;
		} else {
			ans = S;
		}
		jump = ans+1;
		S += jump;
	}
	return ans;
}
			
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...