Submission #1262779

#TimeUsernameProblemLanguageResultExecution timeMemory
1262779yf_yusufGap (APIO16_gap)C++20
Compilation error
0 ms0 KiB
//```//    YF YUSUF
#define YF ios_base::sync_with_stdio(0);cout.setf(ios::fixed);
#define YUSUF cout.precision(0);cout.tie(0);cin.tie(0);
// #include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <queue>
#include <stack>
#include <cassert>
#include <climits>
#include <string>
#include <cstdlib>
#include <random>
#include <ctime>
using namespace std;
#ifdef YF_CHECK
	bool Output=1;
#else
	#pragma GCC optimize ("unroll-loops")
	#pragma GCC optimize ("inline")
	#pragma GCC optimize ("Ofast")
	#pragma GCC optimize ("O3")
	bool Output=0;
#endif
using ll   = long long;
using ld   = long double;
using sll  = set <ll>;
using vll  = vector <ll>;
using mll  = map <ll,ll>;
using pll  = pair <ll,ll>;
using vvl  = vector <vll>;
using vpll = vector <pll>;
template<class T>T MIN(T&a,T b){a=min(a,b);return a;}
template<class T>T MAX(T&a,T b){a=max(a,b);return a;}
#define all(a) a.begin(),a.end()
#define sgr v+v+1,(tl+tr)/2+1,tr
#define sgl v+v,tl,(tl+tr)/2
#define pb push_back
#define ins insert
#define S second
#define F first
mt19937_64 MT(time(0));
ll BP(ll a,ll b,ll mod=1e9+7){
	if(b==0)return 1;
	ll q=BP(a,b/2,mod);
	return ((q*q)%mod*(b%2?a:1ll))%mod;
}
ll f(ll x){return x*(x+1)/2;}
ll dup(ll a,ll b){return (a+b-1)/b;}
ll lcm(ll a,ll b){return a/__gcd(a,b)*b;}
ll invf(ll x){return (-1+sqrt(1+8*x))/2;}
const ll  mod=998244353;
const ll  INF=1e18;
const ll  inf=1e9+7;
const ll  N  =1e6+7;
vll b(N);
ll 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 (b[mid] >= s) hi = mid - 1, left = mid;
		else lo = mid + 1;
	}
	lo = 1, hi = n;
	while (lo <= hi){
		int mid = (lo+hi)>>1;
		if (b[mid] <= t) lo = mid + 1, right = mid;
		else hi = mid - 1;
	}
	if (left > right) *mn = *mx = -1;
	else{
		*mn = b[left];
		*mx = b[right];
	}
}
set<ll>st;
void dac(ll l,ll r){
	if(l > r)return;
	ll m = (l+r)/2;
	ll x=-1,y,X=-1,Y;
	if(l<=m)MinMax(l, m, &x, &y);
	if(m+1<=r)MinMax(m+1, r, &X, &Y);
	if(x!=-1){
		st.ins(x);
		st.ins(y);
		dac(x+1,y-1);
	}
	if(X!=-1){
		st.ins(X);
		st.ins(Y);
		dac(X+1, Y-1);
	}
}
void YF_MAIN(ll TEST){
	st.clear();
	cin>>n;
	for(int i=1;i<=n;i++)cin>>b[i];
	vll a(n+1);
	{
		ll l = 0ll, r = (1000000000000000000LL);
		MinMax(l, r, &a[1], &a[n]);
	}
	dac(a[1]+1, a[n]-1);
	st.ins(a[1]);
	st.ins(a[n]);
	// return;
	ll cnt = 0;
	for(auto i : st)a[++cnt] = i;
	ll mx = 0;
	for(int i=1;i<=n;i++)cout<<b[i]<<" ";cout<<"\n";
	for(int i=1;i<=n;i++){
		if(i>1)MAX(mx, a[i] - a[i-1]);
		cout<<a[i]<<" ";
	}
	cout<<"\n";
	cout<<mx;
}
bool TECT=1;
bool OUTP=1;
ll lg(ll x){return (x ? 63 - __builtin_clzll(x) : -1);}
const ll SN=2e0 + 7; ll SM[SN];
const ll FN=2e0 + 7; ll FACT[FN], inv[FN], FMOD=inf;
ll PER(ll n,ll k){return FACT[n] *inv[n-k]%FMOD;}
ll CNK(ll n,ll k){return PER(n,k)*inv[k  ]%FMOD;}
void BEFORE(){
	
	for(ll i=2;i<SN;i++){
		if(SM[i])continue;
		for(ll j=i;j<SN;j+=i)
			MAX(SM[j],i);
	}
	FACT[0]=inv[0]=1;
	for(int i=1;i<FN;i++){
		FACT[i]=FACT[i-1]*i%FMOD;
		if(i<5e5+7)inv[i]=BP(FACT[i],FMOD-2,FMOD);
	}
}
signed main(){
	// freopen(("input.txt"),"r",stdin);freopen(("output.txt"),"w",stdout);
	if(OUTP){YF YUSUF}
	cout<<(0 && Output ? "\nYF_OUTPUT:\n\n" : "");
	int TEST=1;
	if(TECT)
		cin>>TEST;
	BEFORE();
	for(int T=1;T<=TEST;T++){
		// cout<<"Case "<<T<<": ";
		YF_MAIN(T);
		cout<<(T==TEST ? "" : "\n");
	}
	return 0;
} 
//```

Compilation message (stderr)

/usr/bin/ld: /tmp/ccw6oPO1.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/ccGxv0Wg.o:gap.cpp:(.text+0x3d0): first defined here
/usr/bin/ld: /tmp/ccw6oPO1.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccGxv0Wg.o:gap.cpp:(.text.startup+0x0): first defined here
/usr/bin/ld: /tmp/ccw6oPO1.o: in function `main':
grader.cpp:(.text.startup+0x1c2): undefined reference to `findGap(int, int)'
collect2: error: ld returned 1 exit status