Submission #1153375

#TimeUsernameProblemLanguageResultExecution timeMemory
1153375AlgorithmWarriorGap (APIO16_gap)C++20
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>

using namespace std;

#include "gap.h"

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)
{
	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;
}

void maxself(long long& x,long long val){
    if(x<val)
        x=val;
}

long long findGap(int T, int N){
    if(T==1){
        long long st,dr;
        MinMax(0,1e18,&st,&dr);
        long long answer=1;
        while(st!=dr && st!=dr-1){
            long long ultst=st;
            long long ultdr=dr;
            MinMax(ultst+1,ultdr-1,&st,&dr);
            if(st==-1)
                maxself(answer,ultdr-ultst);
            else{
                maxself(answer,st-ultst);
                maxself(answer,ultdr-dr);
            }
        }
        return answer;
    }
}

Compilation message (stderr)

gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:60:1: warning: control reaches end of non-void function [-Wreturn-type]
   60 | }
      | ^
/usr/bin/ld: /tmp/ccI1sj8L.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/ccn26ow0.o:gap.cpp:(.text+0x0): first defined here
collect2: error: ld returned 1 exit status