結果
| 問題 | No.3752 No Use Crying Over Suffixes |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-08-11 10:13:21 |
| 言語 | C++17 (gcc 15.3.0 + boost 1.92.0 + ACL) |
| 結果 |
AC
不安定
|
| 実行時間 | 17 ms / 2,000 ms |
| + 136µs | |
| コード長 | 1,255 bytes |
| 記録 | |
| コンパイル時間 | 349 ms |
| コンパイル使用メモリ | 92,012 KB |
| 実行使用メモリ | 9,900 KB |
| 最終ジャッジ日時 | 2026-10-02 20:54:49 |
| 合計ジャッジ時間 | 2,757 ms |
|
ジャッジサーバーID (参考情報) |
judge2_1 / judge4_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 35 |
ソースコード
#include <iostream>
#include <vector>
using namespace std;
void solve() {
int N;
cin >> N;
vector<long long> A(N);
for (int i = 0; i < N; ++i) {
cin >> A[i];
}
int idx = 0;
bool alice_wins = false;
while (idx < N) {
int c = 0;
// 1 が出現するまで奇数の個数をカウント
while (idx < N && A[idx] != 1) {
if (A[idx] % 2 != 0) {
c++;
}
idx++;
}
// 1 が一つもなく配列の末尾まで到達した場合
if (idx == N) {
alice_wins = (c % 2 != 0);
break;
}
// 1 が出現し、その手前の奇数の個数 C が偶数の場合
if (c % 2 == 0) {
alice_wins = true;
break;
}
// C が奇数の場合は勝敗判定を山 K+1 以降に委ねる
idx++;
}
if (alice_wins) {
cout << "Alice\n";
} else {
cout << "Bob\n";
}
}
int main() {
// 入出力の高速化
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int T;
if (cin >> T) {
while (T--) {
solve();
}
}
return 0;
}