Submission #1075830

#TimeUsernameProblemLanguageResultExecution timeMemory
1075830alexddGap (APIO16_gap)C++17
0 / 100
35 ms1364 KiB
#include "gap.h" #include<bits/stdc++.h> using namespace std; #define int long long const int INF = 1e18; pair<int,int> qry(int le, int ri) { pair<int,int> aux; MinMax(le,ri,&aux.first,&aux.second); return aux; } long long bigsolve(int N) { int rez=1; pair<int,int> tot = qry(0,INF); int cur=tot.first; while(tot.second - cur > rez) { pair<int,int> aux = qry(cur+1,cur+rez); if(aux.first!=-1) { cur = aux.second; continue; } int c=rez; while(1) { c=(c+1)*2; aux = qry(cur+1,cur+c); if(aux.first!=-1) { rez = max(rez, aux.first - cur); cur = aux.second; break; } } } return rez; } int smallsolve(int N) { pair<int,int> tot = qry(0,INF); int le=tot.first,ri=tot.second,rez=1; while(ri-le > rez) { pair<int,int> aux = qry(le+1,ri-1); if(aux.first==-1) break; rez = max(rez, aux.first-le); rez = max(rez, ri-aux.second); le = aux.first; ri = aux.second; } return rez; } long long findGap(int32_t T, int32_t N) { if(T==1 || N<=20) return smallsolve(N); return bigsolve(N); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...