Submission #394437

#TimeUsernameProblemLanguageResultExecution timeMemory
394437VictorGap (APIO16_gap)C++17
30 / 100
51 ms1868 KiB
#include "gap.h" #include <bits/stdc++.h> using namespace std; #define rep(i, a, b) for (int i = a; i < (b); ++i) #define per(i, a, b) for (int i = b - 1; i >= (a); --i) #define trav(a, x) for (auto &a : x) #define all(x) x.begin(), x.end() #define sz(x) x.size() #define pb push_back #define umap unordered_map #define uset unordered_set typedef pair<int, int> ii; typedef pair<int, ii> iii; typedef vector<int> vi; typedef vector<ii> vii; typedef vector<vi> vvi; typedef long long ll; const int INF = 1000000007; ll findGap(int t, int n) { ll ans = 0, lo, hi; MinMax(0, 1e18, &lo, &hi); if (t == 1) { ll arr[n]; arr[0] = lo; arr[n - 1] = hi; rep(i, 0, (n - 1) / 2) { ll lotemp, hitemp; MinMax(lo + 1, hi - 1, &lotemp, &hitemp); lo = lotemp; hi = hitemp; arr[i + 1] = lo; arr[n - i - 2] = hi; } rep(i, 0, n - 1) ans = max(ans, arr[i + 1] - arr[i]); } else { ll gap=(hi-lo+n-2)/n,curr=lo,pos=curr; while(curr!=hi){ ll lo,next; MinMax(curr+1,pos,&lo,&next); if(next==-1)pos+=gap; else{ ans=max(ans,lo-curr); pos=curr=next; pos+=gap; } } } return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...