제출 #1160441

#제출 시각아이디문제언어결과실행 시간메모리
1160441Doncho_BonbonchoGap (APIO16_gap)C++17
컴파일 에러
0 ms0 KiB
#include <algorithm>
#include <random>
#include <stdio.h>
#include <stdlib.h>
#include <vector>

#include "gap.h"
#include <bits/stdc++.h>
using namespace std;

#ifndef LOCAL
#define cerr if(false) cerr
#endif

#define out( x ) #x << " = " << x << "  "
#define endl "\n"

template<class T, class T2> inline bool chkmax(T &x, const T2 &y) { return x < y ? x = y, 1 : 0; }
template<class T, class T2> inline bool chkmin(T &x, const T2 &y) { return x > y ? x = y, 1 : 0; }

typedef long long ll;
const ll mod = 1e9 +7;
const int MAX_N = 1e6 + 42;


static void my_assert(int k){ if (!k) exit(1); }

static int subtask_num, N;
static long long A[100001];
static long long call_count;


void MinMax(long long s, long long t, long long *mn, long long *mx) {
	cerr << out( s ) << out( t ) << endl;
	int lo = 1, hi = N, left = N+1, right = 0;
	my_assert(s <= t && mn != NULL && mx != NULL);
	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];
	}
	if (subtask_num == 1) call_count++;
	else if (subtask_num == 2) call_count += right-left+2;
}


ll a[MAX_N];
long long findGap(int subtask, int n){

	if( subtask == 1 ){


		ll lInd = 0;
		ll rInd = n-1;

		ll mn=0;
		ll mx=1e18;
		while( lInd <= rInd ){
			MinMax( mn, mx, &a[lInd ++],&a[rInd --]);

			mn = a[lInd-1]+1;
			mx = a[rInd+1]-1;
		}

		ll nas = 0;
		for( int i=0 ; i < n-1 ; i++ ){
			cerr << out( i ) << out( a[i+1] - a[i] ) << endl;
			chkmax( nas, ll( a[i+1] - a[i] ) );
		}

		cerr << out( nas ) << endl;
		return nas;
	}else{
		// QJ MI KURA
		return -1;
	}
}

컴파일 시 표준 에러 (stderr) 메시지

/usr/bin/ld: /tmp/cc0iOsoT.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/ccAW8XZf.o:gap.cpp:(.text+0x0): first defined here
collect2: error: ld returned 1 exit status