QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#949780 | #9081. Stone Game | Fatsheep | WA | 0ms | 3584kb | C++23 | 1.1kb | 2025-03-24 12:42:45 | 2025-03-24 12:42:47 |
Judging History
answer
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int T;
cin >> T;
for (int t = 1; t <= T; ++t) {
int n;
cin >> n;
vector<long long> a(n);
for (int i = 0; i < n; ++i) {
cin >> a[i];
}
if (n == 1) {
// If there's only one pile, Alice wins if it's non-zero, otherwise Bob.
cout << "Case " << t << ": " << (a[0] > 0 ? "Alice" : "Bob") << "\n";
continue;
}
long long total = 0;
for (int i = 0; i < n; ++i) {
long long left = (i == 0) ? -1 : a[i-1];
long long right = (i == n-1) ? -1 : a[i+1];
long long max_neighbor = max(left, right);
long long moves = max(0LL, a[i] - max_neighbor);
total += moves;
}
// The winner is determined by the parity of the total moves.
cout << "Case " << t << ": " << (total % 2 ? "Alice" : "Bob") << "\n";
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3584kb
input:
2 2 1 3 3 1 3 1
output:
Case 1: Bob Case 2: Bob
result:
wrong answer 3rd words differ - expected: 'Alice', found: 'Bob'