結果
| 問題 |
No.3342 AAB Game
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-11-13 23:03:35 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 4 ms / 2,000 ms |
| コード長 | 798 bytes |
| コンパイル時間 | 808 ms |
| コンパイル使用メモリ | 77,212 KB |
| 実行使用メモリ | 7,716 KB |
| 最終ジャッジ日時 | 2025-11-13 23:03:45 |
| 合計ジャッジ時間 | 2,128 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 39 |
ソースコード
#include<iostream>
#include<map>
#include<cassert>
using namespace std;
map<string,bool>memo;
bool dfs(string s)
{
if(memo.find(s)!=memo.end())return memo[s];
bool win=false;
for(int j=0;j<s.size();j++)if(s[j]=='B')
{
auto t=s;
t[j]='A';
if(!dfs(t))win=true;
for(int i=j-1;i>=0&&t[i]=='A';i--)
{
t[i]='B';
if(!dfs(t))win=true;
}
}
return memo[s]=win;
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);
/*
for(int len=1;len<=4;len++)
{
for(int i=0;i<1<<len;i++)
{
string s(len,'A');
for(int j=0;j<len;j++)if(i>>j&1)s[j]='B';
cout<<s<<" "<<dfs(s)<<"\n";
assert(dfs(s)==(i%3!=0));
}
}
*/
int N;cin>>N;
string S;cin>>S;
int cur=0;
for(int j=0;j<N;j++)
{
cur=cur*2%3;
if(S[j]=='B')cur=(cur+1)%3;
}
cout<<(cur?"Alice":"Bob")<<endl;
}