Submission #44512

#TimeUsernameProblemLanguageResultExecution timeMemory
44512faustaadpGap (APIO16_gap)C++17
17.68 / 100
152 ms9340 KiB
#include "gap.h"
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define fi first
#define se second
using namespace std;
ll ma,u1,u2,ce,L1,R1,L2,R2,L,R;
priority_queue<pair<ll,pair<ll,ll> > >pq;
long long findGap(int T, int N)
{
	ma=0;
	MinMax(0,(ll)1e18,&L,&R);
	pq.push(mp(R-L,mp(L,R)));
	map<ll,map<ll,bool> >me;
	while(!pq.empty())
	{
		u1=pq.top().se.fi;
		u2=pq.top().se.se;
		pq.pop();
		ce=(u1+u2)/2;
		//cout<<me[u1][u2]<<"\n";
		if(u2-u1<=ma||me[u1][u2]==1)
			continue;
		me[u1][u2]=1;
		//cout<<u1<<" "<<u2<<"\n";
		if(u1+1==u2)
		{
			ma=max(ma,1LL);
			continue;
		}
		MinMax(u1,ce,&L1,&R1);
		if(R1!=u2)	
			MinMax(ce+1,u2,&L2,&R2);
		ma=max(ma,L2-R1);
		if(R1-L1>ma)
			pq.push(mp(R1-L1,mp(L1,R1)));
		if(R2-L2>ma)
			pq.push(mp(R2-L2,mp(L2,R2)));
	}
	return ma;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...