QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#290417#4. GapMoRanSkyCompile Error//C++201.7kb2023-12-24 23:32:472023-12-24 23:32:47

Judging History

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

  • [2023-12-24 23:32:47]
  • 评测
  • [2023-12-24 23:32:47]
  • 提交

answer

#include <bits/stdc++.h>

// Skyqwq
#define pb push_back
#define fi first
#define se second
#define mp make_pair

using namespace std;

typedef pair<int, int> PII;
typedef long long LL;

template <typename T> bool chkMax(T &x, T y) { return (y > x) ? x = y, 1 : 0; }
template <typename T> bool chkMin(T &x, T y) { return (y < x) ? x = y, 1 : 0; }


template <typename T> void inline read(T &x) {
    int f = 1; x = 0; char s = getchar();
    while (s < '0' || s > '9') { if (s == '-') f = -1; s = getchar(); }
    while (s <= '9' && s >= '0') x = x * 10 + (s ^ 48), s = getchar();
    x *= f;
}


void MinMax(LL l, LL r, LL &a, LL &b) {
    printf("? %lld %lld\n", l, r);
    fflush(stdout);
    read(a), read(b);
}

long long findGap(int T, int n)
{	
	if (T == 1) {
		int x = n;
		LL mx, mn;
		vector<LL> a;
		LL L = 0, R = 1e18;
		while (x > 0) {
			MinMax(L, R, mn, mx);
			if (x == 1) {
				a.pb(mx);
				x--;
				break;
			}
			L = mn + 1, R = mx - 1;
			a.pb(mn), a.pb(mx);
			x -= 2;
		}
		sort(a.begin(), a.end());
		LL ans = 0;
		for (int i = 0; i + 1 < a.size(); i++)
			chkMax(ans, a[i + 1] - a[i]);
		return ans;
	} else {
		LL mx, mn;
		LL L = 0, R = 1e18;
		MinMax(L, R, mn, mx);
		LL o = (mx - mn + 1 + n - 2) / (n - 1);
		LL la = -1, ans = 0;
		LL now = mn;
		while (now <= mx) {
			LL rt = min(mx, now + o - 1);
			LL p, q;
			MinMax(now, rt, p, q);
			if (p != -1) {
				if (la != -1) chkMax(ans, p - la);
				la = q;
				chkMax(ans, q - p);
			}
			now = rt + 1;
		}
		return ans;
	}
	return 0;
}

signed main() {
    int t, n;
    read(t), read(n);
    printf("! %lld\n", findGap(t, n));
}

详细

/usr/bin/ld: /tmp/ccZxEbXg.o: in function `main':
answer.code:(.text.startup+0x0): multiple definition of `main'; /tmp/ccEyezWh.o:implementer.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status