結果
| 問題 | No.3752 No Use Crying Over Suffixes |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-08-11 10:06:47 |
| 言語 | C++17 (gcc 15.3.0 + boost 1.92.0 + ACL) |
| 結果 |
TLE
不安定
|
| 実行時間 | - |
| コード長 | 1,423 bytes |
| 記録 | |
| コンパイル時間 | 1,262 ms |
| コンパイル使用メモリ | 227,544 KB |
| 実行使用メモリ | 9,912 KB |
| 最終ジャッジ日時 | 2026-10-02 20:54:35 |
| 合計ジャッジ時間 | 9,477 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 34 TLE * 1 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
map<vector<int>, bool> memo;
bool brute(const vector<int>& A) {
if (memo.count(A)) return memo[A];
int N = A.size();
for (int i = 0; i < N; ++i) {
if (A[i] == 0) continue;
vector<int> B = A;
B[i]--;
if (B[i] == 0) {
for (int j = i; j < N; ++j) {
B[j] = 0;
}
}
if (!brute(B)) {
return memo[A] = true;
}
}
return memo[A] = false;
}
bool solve(const vector<long long>& A) {
long long S = 0;
bool win = false;
for (long long a : A) {
if (a == 1 && S % 2 == 0) {
win = true;
}
S += a;
}
if (S % 2 == 1) {
win = true;
}
return win;
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int T;
cin >> T;
while (T--) {
int N;
cin >> N;
vector<long long> A(N);
long long sum = 0;
for (auto& a : A) {
cin >> a;
sum += a;
}
bool win;
if (sum <= 25) {
vector<int> B(N);
for (int i = 0; i < N; ++i) {
B[i] = (int)A[i];
}
memo.clear();
win = brute(B);
} else {
win = solve(A);
}
cout << (win ? "Alice" : "Bob") << '\n';
}
return 0;
}