QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#202159#4. Gap_LAP_Compile Error//C++14889b2023-10-05 20:22:182023-10-05 20:22:18

Judging History

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

  • [2023-10-05 20:22:18]
  • 评测
  • [2023-10-05 20:22:18]
  • 提交

answer

#include "gap.h"
#include <bits/stdc++.h>

using namespace std;

long long findGap(int T, int n) {
	if(T == 1) {
		vector<long long> a(n + 1);
		long long mn, mx, L = 0, R = 1e18;
		int l = 1, r = n;
		while(l <= r) {
			MinMax(L, R, &mn, &mx);
			a[l ++] = mn; if(l <= r) a[r --] = mx;
			L = mn + 1, R = mx - 1;
		}
		long long res = 0;
		for(int i = 2; i <= n; i ++) res = max(res, a[i] - a[i - 1]);
		return res;
	} else {
		long long mn, mx; MinMax(0ll, (long long)1e18, &mn, &mx);
        long long k = (mx - mn) / (n - 1); if((mx - mn) % (n - 1)) k ++;

        long long lst = mn; long long Maxv = mx;
        for(long long i = mn + 1; i < Maxv; i += k) {
            long long r = min(i + k - 1, Maxv - 1); MinMax(i, r, &mn, &mx);
            ans = max(ans, l - lst); if(mx > 0) lst = mx;
        }
        ans = max(ans, Maxv - lst); return ans;
	}
}

詳細信息

answer.code: In function ‘long long int findGap(int, int)’:
answer.code:26:13: error: ‘ans’ was not declared in this scope; did you mean ‘abs’?
   26 |             ans = max(ans, l - lst); if(mx > 0) lst = mx;
      |             ^~~
      |             abs
answer.code:26:28: error: ‘l’ was not declared in this scope
   26 |             ans = max(ans, l - lst); if(mx > 0) lst = mx;
      |                            ^
answer.code:28:9: error: ‘ans’ was not declared in this scope; did you mean ‘abs’?
   28 |         ans = max(ans, Maxv - lst); return ans;
      |         ^~~
      |         abs