Submission #563749

# Submission time Handle Problem Language Result Execution time Memory
563749 2022-05-18T05:06:00 Z khangal Gap (APIO16_gap) C++14
30 / 100
43 ms 1864 KB
#include "gap.h"
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
typedef double db;
typedef vector<long long> vl;
typedef pair<long long, long long > pl;
#define po pop_back
#define pb push_back
#define mk make_pair
#define lw lower_bound
#define up upper_bound
#define ff first
#define ss second
#define boost ios_base::sync_with_stdio(); cin.tie(0); cout.tie(0);
#define MOD 1000000007
#define MAX 1e18    
#define MIN -1e18
#define per(i,a,b) for(ll i=b;i>=a;i--)
#define con continue
#define freopen freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
#define PI 3.14159265358979323846264338327950288419716939937510582097494459230781640628
// typedef tree<ll , null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
// template< typename T>
// using indexed_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
ll N , n, m, mid, res,pos, mn, mx, sum, h1, h2, arr[3234567],arr1[1234567],k, i, j, h, a, x, y, z,par[1234567],ans;
bool used[1234567];
ll tp[1234567];
ll dx[4]={-1,1,0,0},dy[4]={0,0,-1,1},c1[123][123];
//ll jump[22][223456];
//ll lvl[1234567];
//ll bit[1234567];
//ll timer;
//ll st[1234567],endd[1234567];
//ll dp[5005][5005];
ll findGap(int T, int n){
	ll l=0,r=MAX,mn,mx;
	if(T==1){
		for(int i=1;i<=(n+1)/2;i++){
			MinMax(l,r,&mn,&mx);
			arr[i] = mn;
			arr[n+1-i] = mx;
			l = mn+1;
			r = mx-1;
		}
		ans=0;
		for(int i=1;i<n;i++)ans=max(ans,arr[i+1]-arr[i]);
		return ans;
	}
	else{
		MinMax(l,r,&mn,&mx);
		ll ans = ceil((mx-mn+1)/n);
		while(l!=r){
			MinMax(l+1,l+ans,&mn,&mx);
			if(mx != -1){
				l=mx;
			}
			else{
				x=ans;
				while(mn==-1){
					x*=2;
					MinMax(l+1,l+x,&mn,&mx);
				}
				ans = max(ans , mn-l);
				l=mx;
			}
		}
		return ans;
	}
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 0 ms 336 KB Output is correct
4 Correct 0 ms 336 KB Output is correct
5 Correct 0 ms 336 KB Output is correct
6 Correct 0 ms 336 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 0 ms 336 KB Output is correct
9 Correct 0 ms 336 KB Output is correct
10 Correct 0 ms 336 KB Output is correct
11 Correct 1 ms 336 KB Output is correct
12 Correct 1 ms 336 KB Output is correct
13 Correct 1 ms 336 KB Output is correct
14 Correct 1 ms 336 KB Output is correct
15 Correct 1 ms 336 KB Output is correct
16 Correct 10 ms 676 KB Output is correct
17 Correct 11 ms 688 KB Output is correct
18 Correct 10 ms 644 KB Output is correct
19 Correct 10 ms 720 KB Output is correct
20 Correct 8 ms 720 KB Output is correct
21 Correct 38 ms 1860 KB Output is correct
22 Correct 40 ms 1856 KB Output is correct
23 Correct 38 ms 1836 KB Output is correct
24 Correct 43 ms 1784 KB Output is correct
25 Correct 38 ms 1820 KB Output is correct
26 Correct 38 ms 1864 KB Output is correct
27 Correct 38 ms 1864 KB Output is correct
28 Correct 39 ms 1820 KB Output is correct
29 Correct 41 ms 1820 KB Output is correct
30 Correct 34 ms 1856 KB Output is correct
31 Correct 0 ms 336 KB Output is correct
32 Correct 0 ms 336 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 208 KB Execution failed because the return code was nonzero
2 Runtime error 0 ms 336 KB Execution failed because the return code was nonzero
3 Runtime error 0 ms 336 KB Execution failed because the return code was nonzero
4 Runtime error 0 ms 336 KB Execution failed because the return code was nonzero
5 Runtime error 0 ms 208 KB Execution failed because the return code was nonzero
6 Runtime error 0 ms 336 KB Execution failed because the return code was nonzero
7 Runtime error 0 ms 208 KB Execution failed because the return code was nonzero
8 Runtime error 0 ms 336 KB Execution failed because the return code was nonzero
9 Runtime error 0 ms 336 KB Execution failed because the return code was nonzero
10 Runtime error 0 ms 336 KB Execution failed because the return code was nonzero
11 Runtime error 1 ms 336 KB Execution failed because the return code was nonzero
12 Runtime error 1 ms 336 KB Execution failed because the return code was nonzero
13 Runtime error 1 ms 336 KB Execution failed because the return code was nonzero
14 Runtime error 1 ms 336 KB Execution failed because the return code was nonzero
15 Runtime error 1 ms 336 KB Execution failed because the return code was nonzero
16 Runtime error 6 ms 464 KB Execution failed because the return code was nonzero
17 Runtime error 7 ms 464 KB Execution failed because the return code was nonzero
18 Runtime error 7 ms 464 KB Execution failed because the return code was nonzero
19 Runtime error 8 ms 468 KB Execution failed because the return code was nonzero
20 Runtime error 4 ms 424 KB Execution failed because the return code was nonzero
21 Runtime error 26 ms 1060 KB Execution failed because the return code was nonzero
22 Runtime error 27 ms 1072 KB Execution failed because the return code was nonzero
23 Runtime error 26 ms 980 KB Execution failed because the return code was nonzero
24 Runtime error 25 ms 1060 KB Execution failed because the return code was nonzero
25 Runtime error 36 ms 1096 KB Execution failed because the return code was nonzero
26 Runtime error 26 ms 988 KB Execution failed because the return code was nonzero
27 Runtime error 25 ms 1104 KB Execution failed because the return code was nonzero
28 Runtime error 27 ms 1036 KB Execution failed because the return code was nonzero
29 Runtime error 28 ms 1064 KB Execution failed because the return code was nonzero
30 Runtime error 14 ms 1048 KB Execution failed because the return code was nonzero
31 Correct 0 ms 336 KB Output is correct
32 Correct 0 ms 208 KB Output is correct