結果

問題 No.3845 eval("G4M3")
コンテスト
ユーザー ぽえ
提出日時 2026-12-03 20:57:39
結果
AC  
実行時間 235 ms / 2,000 ms
+ 605µs
コード長 620 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 2,650 ms
コンパイル使用メモリ 338,764 KB
実行使用メモリ 9,924 KB
最終ジャッジ日時 2026-12-03 20:57:47
合計ジャッジ時間 7,528 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 49
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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

// 面白い!!!

void solve() {
	int n; string s; cin >> n >> s;

	vector<int> a(n); for (int i=0; i<n; i++) a[i] = (s[i]-'0') % 2;
	if (n%2 == 0) {
		if (a.front() | a.back()) { cout << "Alice" << '\n'; return; }
		for (int i=0; i<n-1; i++) if (a[i] & a[i+1]) { cout << "Alice" << '\n'; return; }
		cout << "Bob" << '\n';
	} else {
		if (a.front() == a.back()) { cout << "Bob" << '\n'; return; }
		for (int i=0; i<n-1; i++) if (a[i] & a[i+1]) { cout << "Bob" << '\n'; return; }
		cout << "Alice" << '\n';
	}
}

int main() {
	int T; cin >> T;
	while (T--) solve();
}
0