Submission #908648

# Submission time Handle Problem Language Result Execution time Memory
908648 2024-01-16T15:53:48 Z ByeWorld Gap (APIO16_gap) C++14
100 / 100
67 ms 7384 KB
#include "gap.h"
#include <bits/stdc++.h>
#define bupol __builtin_popcount
//#define int long long 
#define ll long long
#define ld long double
#define fi first
#define se second
#define pb push_back
#define lf (id<<1)
#define rg ((id<<1)|1)
#define md ((l+r)>>1)
using namespace std;
const int MAXN = 1e5+5;
const int MAXK = 205;
const int LOG = 20;
const int MOD = 1e9+7;
const int SQRT = 520;
const ll INF = 1e18;
typedef pair<ll,ll> pii;
typedef pair<ll,pii> ipii;

ll mn, mx;
int n;
set<ll> s; ll ans = -INF;
ll le, ri, nx;
ll x, y;
ll a[MAXN];

long long findGap(int T, int N)
{
	if(T==1){
		n = N;
		x = 0; y = INF;
		for(int i=1; i<=(n+1)/2; i++){
			MinMax(x, y, &mn, &mx);
			a[i] = mn; a[n-i+1] = mx;
			//cout << mn << ' '<< mx << " p\n";
			x = mn+1; y = mx-1;
		}
		for(int i=1; i<=n-1; i++){
			ans = max(ans, a[i+1]-a[i]);
		}
		return ans;
	}
	n = N;
	MinMax(0, INF, &mn, &mx); le = mn; ri = mx;
	s.insert(mn); s.insert(mx);

	ll len = mx-mn-1, idx = mn;
	for(ll i=1; i<=n-2; i++){ // n+1 segment
		nx = len / (n-2) * i + le;
		if(idx+1 <= nx){
			//cout << idx+1 << ' ' << nx << " p\n";
			MinMax(idx+1, nx, &mn, &mx);
			s.insert(mn); s.insert(mx);
		}

		idx = nx;
	}

	nx = ri-1;
	if(idx+1 <= nx){
		//cout << idx+1 << ' ' << nx << " p\n";
		MinMax(idx+1, nx, &mn, &mx);
		s.insert(mn); s.insert(mx);
	}
	//for(auto in : s) cout << in << " xx\n";
	auto it = s.begin(); ll las = -1;
	while(it != s.end()){
		if(las != -1) ans = max(ans, (*it)-las);
		las = (*it); it++;
	}
	//for(auto in : s) cout << in << " in\n";
	return ans;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 2392 KB Output is correct
3 Correct 1 ms 2392 KB Output is correct
4 Correct 1 ms 2484 KB Output is correct
5 Correct 1 ms 2392 KB Output is correct
6 Correct 1 ms 2392 KB Output is correct
7 Correct 1 ms 2392 KB Output is correct
8 Correct 1 ms 2392 KB Output is correct
9 Correct 1 ms 2392 KB Output is correct
10 Correct 1 ms 2392 KB Output is correct
11 Correct 1 ms 2392 KB Output is correct
12 Correct 1 ms 2400 KB Output is correct
13 Correct 2 ms 2392 KB Output is correct
14 Correct 1 ms 2392 KB Output is correct
15 Correct 1 ms 2392 KB Output is correct
16 Correct 7 ms 2596 KB Output is correct
17 Correct 7 ms 2592 KB Output is correct
18 Correct 7 ms 2592 KB Output is correct
19 Correct 8 ms 2752 KB Output is correct
20 Correct 6 ms 2580 KB Output is correct
21 Correct 28 ms 3032 KB Output is correct
22 Correct 28 ms 2900 KB Output is correct
23 Correct 34 ms 2856 KB Output is correct
24 Correct 27 ms 2868 KB Output is correct
25 Correct 25 ms 2868 KB Output is correct
26 Correct 27 ms 3112 KB Output is correct
27 Correct 28 ms 2876 KB Output is correct
28 Correct 28 ms 2876 KB Output is correct
29 Correct 32 ms 2852 KB Output is correct
30 Correct 26 ms 2872 KB Output is correct
31 Correct 1 ms 2392 KB Output is correct
32 Correct 1 ms 2400 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2564 KB Output is correct
2 Correct 1 ms 2392 KB Output is correct
3 Correct 1 ms 2392 KB Output is correct
4 Correct 1 ms 2392 KB Output is correct
5 Correct 1 ms 2392 KB Output is correct
6 Correct 1 ms 2392 KB Output is correct
7 Correct 1 ms 2392 KB Output is correct
8 Correct 1 ms 2392 KB Output is correct
9 Correct 1 ms 2392 KB Output is correct
10 Correct 1 ms 2392 KB Output is correct
11 Correct 2 ms 2392 KB Output is correct
12 Correct 2 ms 2392 KB Output is correct
13 Correct 2 ms 2392 KB Output is correct
14 Correct 2 ms 2392 KB Output is correct
15 Correct 1 ms 2392 KB Output is correct
16 Correct 15 ms 3580 KB Output is correct
17 Correct 14 ms 3608 KB Output is correct
18 Correct 15 ms 3620 KB Output is correct
19 Correct 16 ms 3416 KB Output is correct
20 Correct 6 ms 2576 KB Output is correct
21 Correct 60 ms 7056 KB Output is correct
22 Correct 65 ms 7072 KB Output is correct
23 Correct 61 ms 6968 KB Output is correct
24 Correct 65 ms 6984 KB Output is correct
25 Correct 67 ms 7384 KB Output is correct
26 Correct 64 ms 6916 KB Output is correct
27 Correct 60 ms 6928 KB Output is correct
28 Correct 62 ms 7024 KB Output is correct
29 Correct 60 ms 6968 KB Output is correct
30 Correct 26 ms 3380 KB Output is correct
31 Correct 1 ms 2392 KB Output is correct
32 Correct 1 ms 2388 KB Output is correct