結果
| 問題 |
No.2814 Block Game
|
| コンテスト | |
| ユーザー |
沙耶花
|
| 提出日時 | 2024-07-19 22:05:51 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 484 ms / 2,000 ms |
| コード長 | 1,880 bytes |
| コンパイル時間 | 4,098 ms |
| コンパイル使用メモリ | 253,416 KB |
| 最終ジャッジ日時 | 2025-02-23 16:34:45 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 20 |
ソースコード
#include <stdio.h>
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace atcoder;
using mint = modint998244353;
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define Inf32 1000000001
#define Inf64 1000000000000000001
string solve(long long x,long long y,long long z,long long w,string s){
long long n = x+y;
if(y==0){
if((z%2==0)==(s[0]=='E')){
return "Alice";
}
else{
return "Bob";
}
}
if(w==0){
if((x%2==0)==(s[0]=='O'))cout<<"Alice"<<endl;
else return "Bob";
}
if(x==1||y==1||z==1||w==1){
return "Alice";
}
long long sum = (x-2) + (y-2);
if(sum%2==0){
return "Bob";
}
else{
return "Alice";
}
}
string get(long long x,long long y,long long z,long long w,string s,long long cur = 0,int turn = 0){
if(x+y==0){
if((cur%2==0) ==( s[0]=='E'))return "Alice";
else return "Bob";
}
bool f = false;
if(x>0&&z>0){
string t = get(x-1,y,z-1,w,s,cur^1,turn^1);
if(t[0]-'A'==turn)f = true;
}
if(x>0&&w>0){
string t = get(x-1,y,z,w-1,s,cur,turn^1);
if(t[0]-'A'==turn)f = true;
}
if(y>0&&z>0){
string t = get(x,y-1,z-1,w,s,cur,turn^1);
if(t[0]-'A'==turn)f = true;
}
if(y>0&&w>0){
string t = get(x,y-1,z,w-1,s,cur,turn^1);
if(t[0]-'A'==turn)f = true;
}
if(f == (turn==0))return "Alice";
else return "Bob";{
}
}
int main(){/*
int n;
cin>>n;
rep(i,n+1){
rep(j,n+1){
int x = i,y = n-i,z = j,w = n-j;
if(x==0||z==0)continue;
if(z-w<0||z-w>=2)continue;
if(solve(x,y,z,w,"E") != get(x,y,z,w,"E")){
cout<<x<<" "<<y<<" "<<z<<" "<<w<<endl;
cout<<solve(x,y,z,w,"E")<<" "<<get(x,y,z,w,"E")<<endl;
}
}
}*/
int _t;
cin>>_t;
rep(_,_t){
long long n;
cin>>n;
string s;
cin>>s;
long long x = 1LL;
rep(j,60){
if(((n-1)>>j)&1)x*=2;
}
long long y = n-x;
long long z = (n+1)/2;
long long w = n-z;
cout<<solve(x,y,z,w,s)<<endl;
}
return 0;
}
沙耶花