QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#621921#8145. GameXlonelywolf#WA 1ms3864kbC++201.4kb2024-10-08 18:19:172024-10-08 18:19:18

Judging History

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

  • [2024-10-08 18:19:18]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3864kb
  • [2024-10-08 18:19:17]
  • 提交

answer

#include <bits/stdc++.h>  
using namespace std;  

#define int long long  

void solve() {
	int n, k;
	cin >> n >> k;

	vector<int> a(n + 1);
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
	}
	sort(a.begin() + 1, a.end());
	// for (int i = 1; i <= n; i++) {
	// 	cout << a[i] << " \n"[i == n];
	// }

	vector<pair<int, int>> v;
	int now = 1;
	while (now <= n) {
		auto check = [&](int x) {
			return (a[x] - a[now] == x - now);
		};
		int l = now - 1, r = n + 1;
		while (l + 1 != r) {
			int mid = (l + r) / 2;
			if (check(mid)) {
				l = mid;
			} else {
				r = mid;
			}
		}
		v.push_back({a[now], a[l]});
		now = l + 1;
	}

	vector<pair<int, int>> t;
	if (v[0].first != 0) {
		t.emplace_back(0, v[0].first - 1);
	}
	for (int i = 1; i < v.size(); i++) {
		t.emplace_back(v[i - 1].second + 1, v[i].first - 1);
	}

	t.emplace_back(v.back().second + 1, 1e18);

	int s = 2 * k;
	for (auto [l, r] : t) {
		int len = r - l + 1;
		if (s >= len) {
			s -= len;
		} else {
			if (l % 2) {
				if (s % 2) {
					cout << "Alice\n";
				} else {
					cout << "Bob\n";
				}
				return;
			} else {
				if (s % 2 == 0) {
					cout << "Alice\n";
				} else {
					cout << "Bob\n";
				}
				return;
			}
		}
	}
}

signed main() {  
    ios::sync_with_stdio(false);
    cin.tie(nullptr);  

    int t;
    cin >> t;
    while (t--) {
    	solve();
    }

    return 0;
}  
  

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3640kb

input:

5
14 5
7 13 1 6 14 2 16 17 18 19 34 36 20 23
13 5
8 10 3 13 14 15 16 17 18 19 20 36 38
14 5
14 20 12 6 0 16 8 11 9 17 13 3 5 19
14 5
15 7 13 3 1 17 16 14 0 12 4 10 22 53
14 5
7 3 4 0 14 15 16 17 18 19 20 21 22 23

output:

Bob
Bob
Alice
Bob
Alice

result:

ok 5 tokens

Test #2:

score: 0
Accepted
time: 0ms
memory: 3616kb

input:

10
19 10
23 1 15 29 13 4 10 8 26 16 30 46 60 43 51 56 31 59 53
19 9
3 7 13 23 1 21 25 8 10 22 32 2 26 20 4 41 52 51 57
19 10
18 26 12 10 2 5 17 21 15 29 30 31 32 33 34 35 36 37 38
20 9
32 16 26 0 18 22 2 34 20 23 31 9 29 17 1 33 11 35 36 61
20 9
34 8 28 14 22 6 10 36 32 20 1 21 25 3 27 23 11 5 19 37...

output:

Alice
Bob
Bob
Bob
Alice
Alice
Alice
Bob
Alice
Bob

result:

ok 10 tokens

Test #3:

score: -100
Wrong Answer
time: 1ms
memory: 3864kb

input:

10
195 181
40 276 550 44 306 438 532 72 166 476 88 190 120 296 466 366 86 106 2 162 436 442 372 448 12 184 552 102 270 68 416 364 230 154 492 548 198 410 456 148 524 232 302 460 244 16 214 478 152 146 288 468 122 374 76 332 358 344 512 64 450 444 238 494 336 530 334 426 414 502 14 156 212 536 474 30...

output:

Alice
Bob
Alice
Alice
Bob
Bob
Alice
Bob
Alice
Bob

result:

wrong answer 2nd words differ - expected: 'Alice', found: 'Bob'