QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#492116#4. GapKiharaTouma#Compile Error//C++23867b2024-07-26 09:34:282024-07-26 09:34:28

Judging History

你现在查看的是最新测评结果

  • [2024-07-26 09:34:28]
  • 评测
  • [2024-07-26 09:34:28]
  • 提交

answer

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

long long findGap(int T, int n){
	static long long a[100010];
	memset(a, 0, sizeof(a));
	if(T == 1){
		a[0] = -3, a[n+1] = 2e18;
		for(int i = 1, j = n; i <= j; ++ i, -- j){
			MinMax(a[i-1] + 1, a[j+1] - 1, &a[i], &a[j]);
		}
		long long mx = 0;
		for(int i = 1; i < n; ++ i){
			mx = max(mx, a[i+1] - a[i]);
		}
		return mx;
	} else {
		long long mn, mx;
		MinMax(-3, 2e18, &mn, &mx);
		long long k = (mx - mn - 1) / (n - 1) + 1;
		int cnt = 0;
		a[++cnt] = mn;
		a[++cnt] = mx;
		for(long long i = mn; i <= mx; i += k){
			long long tx, ty;
			MinMax(i, min(i+k-1, mx), &tx, &ty);
			a[++cnt] = tx;
			a[++cnt] = ty;
		}
		sort(a + 1, a + cnt + 1);
		long long mx = 0;
		for(int i = 1; i < cnt; ++ i){
			mx = max(mx, a[i+1] - a[i]);
		}
		return mx;
	}
}

Details

answer.code: In function ‘long long int findGap(int, int)’:
answer.code:33:27: error: redeclaration of ‘long long int mx’
   33 |                 long long mx = 0;
      |                           ^~
answer.code:20:31: note: ‘long long int mx’ previously declared here
   20 |                 long long mn, mx;
      |                               ^~