Submission #909816

# Submission time Handle Problem Language Result Execution time Memory
909816 2024-01-17T12:52:22 Z oblantis Gap (APIO16_gap) C++17
Compilation error
0 ms 0 KB
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
#pragma GCC optimize("O3,unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
//#include "gap.h"
#define all(v) v.begin(), v.end()
#define pb push_back
#define ss second
#define ff first
#define vt vector
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef pair<int, int> pii;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
const ll inf = 1e18;
const int mod = 1e9+7;
const int maxn = 1e5 + 1;
long long A[100001];
int N;

void MinMax(long long s, long long t, long long *mn, long long *mx)
{
	int lo = 1, hi = N, left = N+1, right = 0;
	while (lo <= hi){
		int mid = (lo+hi)>>1;
		if (A[mid] >= s) hi = mid - 1, left = mid;
		else lo = mid + 1;
	}
	lo = 1, hi = N;
	while (lo <= hi){
		int mid = (lo+hi)>>1;
		if (A[mid] <= t) lo = mid + 1, right = mid;
		else hi = mid - 1;
	}
	if (left > right) *mn = *mx = -1;
	else{
		*mn = A[left];
		*mx = A[right];
	}
}
long long findGap(int t, int n){
	ll l, r;
	MinMax(0, inf, &l, &r);
	ll x = l + 1, bf = l;
	ll ret = (r - l + n - 2) / (n - 1);
	while(x < r){
		ll mn = -1, mx = -1;
		while(mn == -1){
			MinMax(x, x + ret, &mn, &mx);
			if(mn == -1)x = x + ret + 1;
		}
		ret = max(ret, mn - bf);
		bf = mx;
		x = bf + 1;
	}
	return ret;
}
int main(){
	cin >> N >> N;
	for(int i = 1; i <= N; i++){
		cin >> A[i];
	}
	cout << findGap(N, N);
	return 0;
}

Compilation message

/usr/bin/ld: /tmp/cc8kPm0z.o: in function `MinMax(long long, long long, long long*, long long*)':
grader.cpp:(.text+0x0): multiple definition of `MinMax(long long, long long, long long*, long long*)'; /tmp/ccLBgxzB.o:gap.cpp:(.text+0x0): first defined here
/usr/bin/ld: /tmp/cc8kPm0z.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccLBgxzB.o:gap.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status