Submission #1092474

#TimeUsernameProblemLanguageResultExecution timeMemory
1092474alexander707070Gap (APIO16_gap)C++14
17.94 / 100
99 ms10940 KiB
#include<bits/stdc++.h> #include "gap.h" #define MAXN 600007 using namespace std; struct interval{ long long from,to; inline friend bool operator < (interval fr,interval sc){ return fr.to-fr.from<sc.to-sc.from; } }; priority_queue<interval> q; interval check(long long l,long long r){ if(l+1==r)return {-1,-1}; long long mid=(l+r)/2; long long *ll,*rr,*lt,*rt; ll=new long long(); rr=new long long(); lt=new long long(); rt=new long long(); MinMax(l+1,mid, ll,rr); MinMax(mid,r-1, lt,rt); return {*rr,*lt}; } const long long inf=1e18; long long *l,*r; long long findGap(int T, int N){ while(!q.empty())q.pop(); l=new long long(); r=new long long(); MinMax(1, inf, l,r); q.push({*l,*r}); while(true){ interval s=check(q.top().from,q.top().to); if(s.from==-1 and s.to==-1)return q.top().to-q.top().from; interval z=q.top(); q.pop(); if(s.from==-1)s.from=s.to; if(s.to==-1)s.to=s.from; if(z.from!=s.from)q.push({z.from,s.from}); if(s.from!=s.to)q.push(s); if(s.to!=z.to)q.push({s.to,z.to}); } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...