交互题(apio2016Gap)

2021-04-13 08:27

阅读:560

标签:链接   main   print   oid   bre   def   http   names   highlight   

题目链接

 
//Serene
#include
#include
#include
#include
#include
#include
#include "gap.h"
using namespace std;
#define ll long long
#define db double
#define For(i,a,b) for(int i=(a);i=(b);--i)

ll findGap(int T,int N) {
	ll n=(N+1)>>1,l=0,r=1e18,ld,rd,rs=0,fl=0,len;
	if(T==1) {
		MinMax(l,r,&ld,&rd); l=ld; r=rd;
		For(i,1,n-1) {
			MinMax(l+1,r-1,&ld,&rd);
			rs=max(rs,ld-l); rs=max(rs,r-rd);
			l=ld; r=rd;
			if((r-1)-(l+1)

 

编译:

g++ -g gap.cpp grader.cpp -o gap

 

grader.cpp

#include 
#include 

#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;

long long findGap(int, int);

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 >1;
		if (A[mid] >= s) hi = mid - 1, left = mid;
		else lo = mid + 1;
	}
	lo = 1, hi = N;
	while (lo >1;
		if (A[mid]  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;
}

int main()
{
//	freopen("gap.in","r",stdin);
//	freopen("gap.out","w",stdout);
	FILE *in = stdin, *out = stdout;
	my_assert(2 == fscanf(in, "%d%d", &subtask_num, &N));
	my_assert(1 

gap.h

void MinMax(long long, long long, long long*, long long*);

 

交互题(apio2016Gap)

标签:链接   main   print   oid   bre   def   http   names   highlight   

原文地址:https://www.cnblogs.com/Serene-shixinyi/p/8984759.html


评论


亲,登录后才可以留言!