Submission #1029919

# Submission time Handle Problem Language Result Execution time Memory
1029919 2024-07-21T13:51:44 Z KasymK Gap (APIO16_gap) C++17
Compilation error
0 ms 0 KB
#include "bits/stdc++.h"
#include "gap.h"
using namespace std;
#define ff first
#define ss second
#define all(v) v.begin(), v.end()
#define ll long long
#define pb push_back
#define pii pair<int, int>
template<class T>bool umin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T>bool umax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
const int MOD = 1e9+7;
const int N = 1e5+5;
ll a[N];

ll findGap(int t, int n){
	if(t == 1){
		ll l = 0, r = 1e18, id = 0, mn, mx, ans = 0;
        for(int i = 0; i < (n+1)/2; ++i){
            MinMax(l, r, &mn, &mx);
            a[id++] = mn, a[id++] = mx, l = mn+1, r = mx-1;
        }
        sort(a, a+n);
        for(int i = 0; i < n-1; ++i)
        	umax(ans, a[i+1]-a[i]);
        return ans;
    }
    ll a_, b_, mn, mx, id = 0, l = 0, r = 1e18;
	MinMax(l, r, &mn, &mx);
	ll d = (mx-mn-1)/(n-1);
	a[id++] = mn;
	for(ll i = mn+1; i < mx; i+=d+1){
		MinMax(i, min(i+d, mx-1), &a_, &b_);
		if(a_ != -1)	
			a[id++] = a_, a[id++] = b_;
	}
	a[id++] = mx;
	int id = -1;
	for(int i = 0;; ++i)
		if(a[i]){
			id = i;
			break;
		}
	ll ans = 0;
	for(int i = 0; i < id; ++i)
		umax(ans, a[i+1]-a[i]);
	return ans;
}

Compilation message

gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:38:6: error: conflicting declaration 'int id'
   38 |  int id = -1;
      |      ^~
gap.cpp:28:24: note: previous declaration as 'long long int id'
   28 |     ll a_, b_, mn, mx, id = 0, l = 0, r = 1e18;
      |                        ^~