結果

問題 No.3845 eval("G4M3")
コンテスト
ユーザー marc2825
提出日時 2026-10-11 13:25:18
結果
AC  
実行時間 11 ms / 2,000 ms
+ 984µs
コード長 979 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,256 ms
コンパイル使用メモリ 217,656 KB
実行使用メモリ 9,920 KB
最終ジャッジ日時 2026-12-02 23:30:53
合計ジャッジ時間 3,941 ms
ジャッジサーバーID
(参考情報)
judge6_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 49
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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

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

    int T;
    cin >> T;

    while (T--) {
        int N;
        string S;
        cin >> N >> S;

        const bool left_odd = ((S.front() - '0') % 2 == 1);
        const bool right_odd = ((S.back() - '0') % 2 == 1);

        bool has_adjacent_odds = false;

        for (int i = 0; i + 1 < N; ++i) {
            const bool current_odd = ((S[i] - '0') % 2 == 1);
            const bool next_odd = ((S[i + 1] - '0') % 2 == 1);

            if (current_odd && next_odd) {
                has_adjacent_odds = true;
                break;
            }
        }

        bool alice_wins;

        if (N % 2 == 0) {
            alice_wins = left_odd || right_odd || has_adjacent_odds;
        } else {
            alice_wins = (left_odd != right_odd) && !has_adjacent_odds;
        }

        cout << (alice_wins ? "Alice" : "Bob") << '\n';
    }

    return 0;
}
0