QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#196039#6510. Best Carry Player 3maoxuyiWA 0ms3948kbC++14912b2023-10-01 11:16:432023-10-01 11:16:44

Judging History

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

  • [2023-10-01 11:16:44]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3948kb
  • [2023-10-01 11:16:43]
  • 提交

answer

#include <bits/stdc++.h>
typedef long long LL;
using namespace std;
inline int qtop (long long x) {
printf("Query top:%lld\n", x);
	int t;
	while (x) {
		t++;
		x >>= 1;
printf("%d:%lld\n", t, x);
	}
	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 %d\n", min(ans, 2ll), topk);
			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: 3948kb

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:

Query top:0
1
Query top:3
-838024335:1
-838024334:0
2 -838024334
Query top:6
-838024333:3
-838024332:1
-838024331:0
2 -838024331
Query top:5
-838024330:2
-838024329:1
-838024328:0
2 -838024328
Query top:8
-838024327:4
-838024326:2
-838024325:1
-838024324:0
2 -838024324
Query top:38
-838024323:19
-83...

result:

wrong output format Expected integer, but "Query" found