QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#196021#6510. Best Carry Player 3maoxuyiWA 0ms3904kbC++14841b2023-10-01 11:02:472023-10-01 11:02:48

Judging History

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

  • [2023-10-01 11:02:48]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3904kb
  • [2023-10-01 11:02:47]
  • 提交

answer

#include <bits/stdc++.h>
typedef long long LL;
using namespace std;
inline int qtop (int x) {
	int t;
	while (x) {
		t++;
		x >>= 1;
	}
	return t;
}
int main () {
	int T;
	scanf("%d", &T);
	while (T--) {
		LL x, y, k;
		scanf("%lld%lld%lld", &x, &y, &k);
		int topk = qtop(k);
		if (x > y)
			swap(x, y);
		LL ans = y - x, maxn = (1ll<<topk) - 1;
		if (k <= 1) {
			printf("%lld\n", ans);
			continue;
		}
		
		if ((x^y) <= k) {
			printf("%lld\n", min(ans, 1ll));
			continue;
		}else if ((x^y) <= maxn) {
printf("%lld %lld %lld\n", x, y, maxn);
			continue;
		}
		
		LL t = ((x&maxn) == maxn ? 1 : (((x>>topk<<topk ^ x ^ maxn) <= k ? 2: 3)));
		t += (k == maxn ? 2 : 3) * ((y>>topk) - (x>>topk) - 1);
		if (y&maxn)
			t += ((y&maxn) <= k ? 1 : 2);
		printf("%lld\n", min(ans, t));
	}
	return 0;
}

詳細信息

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3904kb

input:

8
4 5 0
5 8 3
9 2 6
15 28 5
97 47 8
164 275 38
114514 1919 810
0 1152921504606846975 1

output:

1
2
2 9 31
15 28 255
47 97 4095
164 275 262143
1919 114514 268435455
1152921504606846975

result:

wrong answer 3rd numbers differ - expected: '3', found: '2'