Submission #242506

#TimeUsernameProblemLanguageResultExecution timeMemory
242506WhaleVomitGap (APIO16_gap)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #include "gap.h" using namespace std; #define f first #define s second #define pb push_back #define mp make_pair #define all(v) v.begin(), v.end() #define sz(v) (int)v.size() #define MOO(i, a, b) for(int i=a; i<b; i++) #define M00(i, a) for(int i=0; i<a; i++) #define MOOd(i,a,b) for(int i = (b)-1; i >= a; i--) #define M00d(i,a) for(int i = (a)-1; i>=0; i--) #define FAST ios::sync_with_stdio(0); cin.tie(0); #define finish(x) return cout << x << '\n', 0; #define dbg(x) cerr << ">>> " << #x << " = " << x << "\n"; #define _ << " _ " << typedef long long ll; typedef long double ld; typedef vector<int> vi; typedef pair<int,int> pi; typedef pair<ld,ld> pd; typedef complex<ld> cd; /*vector<ll> vals; ll m1 = 0; ll m2 = 0; void MinMax(ll s, ll t, ll& mn, ll& mx) { m1++; mn = (1e18)+1; mx = -1; for(ll x: vals) { if(s <= x && x <= t) { mn = min(mn, x); mx = max(mx, x); m2++; } } if(mx == -1) { mn = -1; } }*/ pair<ll,ll> getMinMax(ll s, ll t) { ll mn, mx; MinMax(s, t, mn, mx); return mp(mn, mx); } ll findGap(int t, int n) { if(t == 1) { vector<ll> nums; ll lo = 0; ll hi = 1e18; int cnt = 0; while(cnt < n) { pair<ll,ll> p = getMinMax(lo, hi); if(p.f == p.s) cnt++; else cnt += 2; nums.pb(p.f); nums.pb(p.s); lo = p.f+1; hi = p.s-1; } sort(all(nums)); ll res = 0; M00(i, n-1) { res = max(res, nums[i+1] - nums[i]); } return res; } else { pair<ll,ll> p = getMinMax(0, 1e18); ll small = p.f; ll big = p.s; ll cnt = big-small; if(cnt < n) return 1; ll blockcnt = n; ll a = cnt/n; ll b = a+1; ll bcnt = cnt - a*n; ll acnt = blockcnt - bcnt; vector<pair<ll,ll>> blocks(blockcnt); ll cur = small+1; int numAs = 0; M00(i, blockcnt) { if(numAs < acnt) { blocks[i] = mp(cur, cur+a-1); cur += a; numAs++; } else { blocks[i] = mp(cur, cur+b-1); cur += b; } } vector<pair<ll,ll>> answers(blockcnt); M00(i, blockcnt) answers[i] = getMinMax(blocks[i].f, blocks[i].s); ll res = 0; ll last = small; M00(i, blockcnt) { if(answers[i].f != -1) { res = max(res, answers[i].f - last); last = answers[i].s; } } return res; } } /*bool test(vector<ll> v) { vals = v; ll ans = 0; M00(i, sz(v)-1) { ans = max(ans, v[i+1]-v[i]); } m1 = 0; ll ans1 = findGap(1, sz(v)); if(2*m1 > sz(v)+1 || ans1 != ans) return 0; m2 = 0; ll ans2 = findGap(2, sz(v)); if(m2 > 3*sz(v) || ans2 != ans) return 0; return 1; } int main() { FAST vector<ll> v; v.pb(2); v.pb(3); v.pb(6); v.pb(8); if(test(v)) cout << "OK\n"; else cout << "BAD\n"; v.clear(); v.pb(0); v.pb(1); if(test(v)) cout << "OK\n"; else cout << "BAD\n"; v.clear(); v.pb(1); v.pb(3); v.pb(7); v.pb(9); v.pb(11); if(test(v)) cout << "OK\n"; else cout << "BAD\n"; } */

Compilation message (stderr)

gap.cpp: In function 'std::pair<long long int, long long int> getMinMax(ll, ll)':
gap.cpp:50:24: error: invalid conversion from 'll {aka long long int}' to 'long long int*' [-fpermissive]
     MinMax(s, t, mn, mx);
                        ^
In file included from gap.cpp:2:0:
gap.h:1:6: note:   initializing argument 3 of 'void MinMax(long long int, long long int, long long int*, long long int*)'
 void MinMax(long long, long long, long long*, long long*);
      ^~~~~~
gap.cpp:50:24: error: invalid conversion from 'll {aka long long int}' to 'long long int*' [-fpermissive]
     MinMax(s, t, mn, mx);
                        ^
In file included from gap.cpp:2:0:
gap.h:1:6: note:   initializing argument 4 of 'void MinMax(long long int, long long int, long long int*, long long int*)'
 void MinMax(long long, long long, long long*, long long*);
      ^~~~~~