QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#507710#4. GapHossamHero7Compile Error//C++201.1kb2024-08-06 20:25:142024-08-06 20:25:14

Judging History

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

  • [2024-08-06 20:25:14]
  • 评测
  • [2024-08-06 20:25:14]
  • 提交

answer

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

long long findGap(int t, int n)
{
	if(t == 1){
		vector<ll> a(n);
		ll st = 0;
		ll en = 1e18;
		ll l = 0;
		ll r = n-1;
		while(l <= r){
			MinMax(st,en,&a[l],&a[r]);
			st = a[l]+1;
			en = a[r]-1;
			l ++, r --;
		}
		ll ans = 0;
		for(int i=1;i<n;i++) ans = max(ans , a[i] - a[i-1]);
		return ans;
	}
	else {
		ll l,r;
		MinMax(0,1e18,&l,&r);
		ll b_sz = (r - l - 1) / (n - 1);
		ll mod = (r - l - 1) % (n - 1);
		vector<ll> pos;
		pos.push_back(l);
		cout<<b_sz<<endl;
		for(int i=0;i<n-1-mod;i++){
			ll a,b;
			MinMax((l+1)+i*b_sz,(l+1)+(i+1)*b_sz-1,&a,&b);
			if(a != -1){
				pos.push_back(a);
				pos.push_back(b);
			}
		}
		b_sz ++;
		for(int i=n-1-mod;i<n-1;i++){
			ll a,b;
			MinMax((l+1)+i*b_sz,(l+1)+(i+1)*b_sz-1,&a,&b);
			if(a != -1){
				pos.push_back(a);
				pos.push_back(b);
			}
		}
		pos.push_back(r);
		int sz = pos.size();
		ll ans = 0;
		for(int i=1;i<sz;i++) ans = max(ans , pos[i] - pos[i-1]);
	}
	return ans;
}

详细

answer.code: In function ‘long long int findGap(int, int)’:
answer.code:54:16: error: ‘ans’ was not declared in this scope; did you mean ‘abs’?
   54 |         return ans;
      |                ^~~
      |                abs