QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#247918#7635. Fairy Chessjasonfan#AC ✓914ms3848kbC++202.8kb2023-11-11 16:34:372023-11-11 16:34:38

Judging History

你现在查看的是最新测评结果

  • [2023-11-11 16:34:38]
  • 评测
  • 测评结果:AC
  • 用时:914ms
  • 内存:3848kb
  • [2023-11-11 16:34:37]
  • 提交

answer

#include<bits/stdc++.h>
#define LL long long
#define rep(i,a,b) for(int i=a,i##end=b;i<=i##end;++i)
#define drep(i,a,b) for(int i=a,i##end=b;i>=i##end;--i)
using namespace std;
const int M=205;
const int tx[]={-2,-2,-1,-1,1,1,2,2};
const int ty[]={1,-1,2,-2,2,-2,1,-1};
char s[M];

int atk1_x[M],atk1_y[M];
bool chk_atk1(int x,int y){
    if(atk1_x[x])return 1;
    if(atk1_y[y])return 1;
    return 0;
}
void add_atk1(int x,int y,int z){
    atk1_x[x]+=z;
    atk1_y[y]+=z;
}
int atk2_x[M],atk2_y[M];
bool chk_atk2(int x,int y){
    if(atk2_x[x+y])return 1;
    if(atk2_y[x-y+10])return 1;
    return 0;
}
void add_atk2(int x,int y,int z){
    atk2_x[x+y]+=z;
    atk2_y[x-y+10]+=z;
}
int atk3[M][M];
bool chk_atk3(int x,int y){
    if(atk3[x][y])return 1;
    return 0;
}
void add_atk3(int x,int y,int z){
    rep(i,0,7){
        int ix=x+tx[i];
        int iy=y+ty[i];
        if(ix<1 || ix>8 || iy<1 || iy>8)continue;
        atk3[ix][iy]+=z;
    }
}

int ask1_x[M],ask1_y[M];
bool chk_ask1(int x,int y){
    if(ask1_x[x])return 1;
    if(ask1_y[y])return 1;
    return 0;
}
void add_ask1(int x,int y,int z){
    ask1_x[x]+=z;
    ask1_y[y]+=z;
}
int ask2_x[M],ask2_y[M];
bool chk_ask2(int x,int y){
    if(ask2_x[x+y])return 1;
    if(ask2_y[x-y+10])return 1;
    return 0;
}
void add_ask2(int x,int y,int z){
    ask2_x[x+y]+=z;
    ask2_y[x-y+10]+=z;
}
int ask3[M][M];
bool chk_ask3(int x,int y){
    if(ask3[x][y])return 1;
    return 0;
}
void add_ask3(int x,int y,int z){
    rep(i,0,7){
        int ix=x+tx[i];
        int iy=y+ty[i];
        if(ix<1 || ix>8 || iy<1 || iy>8)continue;
        ask3[ix][iy]+=z;
    }
}
bool dfs(int p){
    rep(x,1,8)rep(y,1,8){
        if(chk_atk1(x,y))continue;
        if(chk_atk2(x,y))continue;
        if(chk_atk3(x,y))continue;
        if((s[p]=='R' || s[p]=='Q' || s[p]=='C' || s[p]=='M') && (chk_ask1(x,y)))continue;
        if((s[p]=='B' || s[p]=='Q' || s[p]=='A' || s[p]=='M') && (chk_ask2(x,y)))continue;
        if((s[p]=='A' || s[p]=='C' || s[p]=='M') && (chk_ask3(x,y)))continue;

        if(s[p]=='R' || s[p]=='Q' || s[p]=='C' || s[p]=='M')add_atk1(x,y,1);
        if(s[p]=='B' || s[p]=='Q' || s[p]=='A' || s[p]=='M')add_atk2(x,y,1);
        if(s[p]=='A' || s[p]=='C' || s[p]=='M')add_atk3(x,y,1);
        add_ask1(x,y,1);
        add_ask2(x,y,1);
        add_ask3(x,y,1);
        int res=dfs(p+1);
        if(s[p]=='R' || s[p]=='Q' || s[p]=='C' || s[p]=='M')add_atk1(x,y,-1);
        if(s[p]=='B' || s[p]=='Q' || s[p]=='A' || s[p]=='M')add_atk2(x,y,-1);
        if(s[p]=='A' || s[p]=='C' || s[p]=='M')add_atk3(x,y,-1);
        add_ask1(x,y,-1);
        add_ask2(x,y,-1);
        add_ask3(x,y,-1);
        if(res)return 0;
    }
    return 1;
}
int main(){
    scanf("%s",s+1);
    puts(dfs(1)?"Bob":"Alice");
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 81ms
memory: 3588kb

input:

BBAARRCCQQMM

output:

Bob

result:

ok single line: 'Bob'

Test #2:

score: 0
Accepted
time: 8ms
memory: 3844kb

input:

BAMBAMQQRCCR

output:

Alice

result:

ok single line: 'Alice'

Test #3:

score: 0
Accepted
time: 3ms
memory: 3784kb

input:

QQRAACMRMCBB

output:

Alice

result:

ok single line: 'Alice'

Test #4:

score: 0
Accepted
time: 13ms
memory: 3840kb

input:

MBBARQRMACQC

output:

Alice

result:

ok single line: 'Alice'

Test #5:

score: 0
Accepted
time: 0ms
memory: 3588kb

input:

ACQCMQRBBRMA

output:

Alice

result:

ok single line: 'Alice'

Test #6:

score: 0
Accepted
time: 6ms
memory: 3840kb

input:

MRCMABRQCQAB

output:

Alice

result:

ok single line: 'Alice'

Test #7:

score: 0
Accepted
time: 9ms
memory: 3588kb

input:

BBRCMMQAAQRC

output:

Alice

result:

ok single line: 'Alice'

Test #8:

score: 0
Accepted
time: 8ms
memory: 3632kb

input:

RRMCQMACABQB

output:

Alice

result:

ok single line: 'Alice'

Test #9:

score: 0
Accepted
time: 9ms
memory: 3844kb

input:

QMQBMRBACACR

output:

Alice

result:

ok single line: 'Alice'

Test #10:

score: 0
Accepted
time: 5ms
memory: 3704kb

input:

CMRQAQCBBRAM

output:

Alice

result:

ok single line: 'Alice'

Test #11:

score: 0
Accepted
time: 12ms
memory: 3632kb

input:

CABCRQMMRQAB

output:

Alice

result:

ok single line: 'Alice'

Test #12:

score: 0
Accepted
time: 37ms
memory: 3592kb

input:

ARCBBCMQRAQM

output:

Alice

result:

ok single line: 'Alice'

Test #13:

score: 0
Accepted
time: 2ms
memory: 3628kb

input:

ARCMCARMQBBQ

output:

Alice

result:

ok single line: 'Alice'

Test #14:

score: 0
Accepted
time: 31ms
memory: 3784kb

input:

AQABMCQCMRRB

output:

Bob

result:

ok single line: 'Bob'

Test #15:

score: 0
Accepted
time: 6ms
memory: 3584kb

input:

ACMRABRQMCBQ

output:

Alice

result:

ok single line: 'Alice'

Test #16:

score: 0
Accepted
time: 26ms
memory: 3692kb

input:

CBARMBCQMQAR

output:

Bob

result:

ok single line: 'Bob'

Test #17:

score: 0
Accepted
time: 37ms
memory: 3844kb

input:

RBABRQMCAMQC

output:

Bob

result:

ok single line: 'Bob'

Test #18:

score: 0
Accepted
time: 2ms
memory: 3752kb

input:

MBCQBQARRMCA

output:

Alice

result:

ok single line: 'Alice'

Test #19:

score: 0
Accepted
time: 19ms
memory: 3624kb

input:

AMBQRBCQACMR

output:

Bob

result:

ok single line: 'Bob'

Test #20:

score: 0
Accepted
time: 1ms
memory: 3768kb

input:

QRAMQMBBCRAC

output:

Alice

result:

ok single line: 'Alice'

Test #21:

score: 0
Accepted
time: 5ms
memory: 3820kb

input:

ARBCQMMBARQC

output:

Alice

result:

ok single line: 'Alice'

Test #22:

score: 0
Accepted
time: 74ms
memory: 3832kb

input:

CACAMBRQQRBM

output:

Bob

result:

ok single line: 'Bob'

Test #23:

score: 0
Accepted
time: 18ms
memory: 3692kb

input:

CQRRMMBQABCA

output:

Bob

result:

ok single line: 'Bob'

Test #24:

score: 0
Accepted
time: 32ms
memory: 3708kb

input:

ABABCQRMMCRQ

output:

Alice

result:

ok single line: 'Alice'

Test #25:

score: 0
Accepted
time: 7ms
memory: 3788kb

input:

CMBRAAQRQMBC

output:

Bob

result:

ok single line: 'Bob'

Test #26:

score: 0
Accepted
time: 2ms
memory: 3708kb

input:

AQBMRMQRBACC

output:

Alice

result:

ok single line: 'Alice'

Test #27:

score: 0
Accepted
time: 16ms
memory: 3788kb

input:

BRACQQMCAMBR

output:

Bob

result:

ok single line: 'Bob'

Test #28:

score: 0
Accepted
time: 5ms
memory: 3768kb

input:

MCCAQBMQRABR

output:

Bob

result:

ok single line: 'Bob'

Test #29:

score: 0
Accepted
time: 27ms
memory: 3588kb

input:

RBQBCRAACMQM

output:

Bob

result:

ok single line: 'Bob'

Test #30:

score: 0
Accepted
time: 10ms
memory: 3844kb

input:

ACRQARMBBQMC

output:

Bob

result:

ok single line: 'Bob'

Test #31:

score: 0
Accepted
time: 1ms
memory: 3768kb

input:

MRCQBCBQRMAA

output:

Alice

result:

ok single line: 'Alice'

Test #32:

score: 0
Accepted
time: 10ms
memory: 3768kb

input:

ACRQQCMMBBAR

output:

Bob

result:

ok single line: 'Bob'

Test #33:

score: 0
Accepted
time: 7ms
memory: 3764kb

input:

MMACQBRQABRC

output:

Bob

result:

ok single line: 'Bob'

Test #34:

score: 0
Accepted
time: 2ms
memory: 3844kb

input:

QACMQABRMCBR

output:

Alice

result:

ok single line: 'Alice'

Test #35:

score: 0
Accepted
time: 11ms
memory: 3756kb

input:

ACAQRCMRMBQB

output:

Alice

result:

ok single line: 'Alice'

Test #36:

score: 0
Accepted
time: 15ms
memory: 3708kb

input:

RABQCQMCABMR

output:

Bob

result:

ok single line: 'Bob'

Test #37:

score: 0
Accepted
time: 7ms
memory: 3760kb

input:

QQBARCRBMMAC

output:

Alice

result:

ok single line: 'Alice'

Test #38:

score: 0
Accepted
time: 1ms
memory: 3820kb

input:

RQMRQABCABCM

output:

Alice

result:

ok single line: 'Alice'

Test #39:

score: 0
Accepted
time: 4ms
memory: 3780kb

input:

RQAMBRQCCBMA

output:

Alice

result:

ok single line: 'Alice'

Test #40:

score: 0
Accepted
time: 2ms
memory: 3692kb

input:

QQBACMARMRBC

output:

Alice

result:

ok single line: 'Alice'

Test #41:

score: 0
Accepted
time: 6ms
memory: 3776kb

input:

QAQCRRAMMCBB

output:

Alice

result:

ok single line: 'Alice'

Test #42:

score: 0
Accepted
time: 9ms
memory: 3692kb

input:

QQBMCBRARMAC

output:

Bob

result:

ok single line: 'Bob'

Test #43:

score: 0
Accepted
time: 101ms
memory: 3692kb

input:

BABARRCCQQMM

output:

Bob

result:

ok single line: 'Bob'

Test #44:

score: 0
Accepted
time: 539ms
memory: 3628kb

input:

BBARARCCQQMM

output:

Alice

result:

ok single line: 'Alice'

Test #45:

score: 0
Accepted
time: 45ms
memory: 3848kb

input:

BBAARCRCQQMM

output:

Alice

result:

ok single line: 'Alice'

Test #46:

score: 0
Accepted
time: 135ms
memory: 3844kb

input:

BBAARRCQCQMM

output:

Bob

result:

ok single line: 'Bob'

Test #47:

score: 0
Accepted
time: 81ms
memory: 3784kb

input:

BBAARRCCQMQM

output:

Bob

result:

ok single line: 'Bob'

Test #48:

score: 0
Accepted
time: 344ms
memory: 3700kb

input:

BBAACCRQMQRM

output:

Bob

result:

ok single line: 'Bob'

Test #49:

score: 0
Accepted
time: 359ms
memory: 3836kb

input:

BACBACQRRQMM

output:

Bob

result:

ok single line: 'Bob'

Test #50:

score: 0
Accepted
time: 914ms
memory: 3764kb

input:

RAABBRCCQQMM

output:

Bob

result:

ok single line: 'Bob'

Test #51:

score: 0
Accepted
time: 57ms
memory: 3584kb

input:

RABRBQMCACQM

output:

Bob

result:

ok single line: 'Bob'

Test #52:

score: 0
Accepted
time: 1ms
memory: 3692kb

input:

CMMQQABCRABR

output:

Alice

result:

ok single line: 'Alice'

Test #53:

score: 0
Accepted
time: 176ms
memory: 3820kb

input:

RBAABRCCQQMM

output:

Alice

result:

ok single line: 'Alice'

Extra Test:

score: 0
Extra Test Passed