QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#236167#7635. Fairy Chessucup-team956#AC ✓1568ms112672kbC++201.9kb2023-11-03 17:27:432023-11-03 17:27:43

Judging History

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

  • [2023-11-03 17:27:43]
  • 评测
  • 测评结果:AC
  • 用时:1568ms
  • 内存:112672kb
  • [2023-11-03 17:27:43]
  • 提交

answer

#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i = a; i <= b; ++i)
using namespace std;
#define ull unsigned long long
string s;
map<array<ull,2>,int> mp[20];
int in(ull S,int bit) {return (S>>bit)&1;}
int pd(int x,int y) {return 0<=x and x<8 and 0<=y and y<8;}
void ban_car(ull &tot,ull &T,ull S,int x,int y) {
    FOR(i,0,7) {
        T|=1ull<<(i*8+y);tot+=in(S,(i*8+y));
        T|=1ull<<(x*8+i);tot+=in(S,(x*8+i));
    }
}
void ban_xiang(ull &tot,ull &T,ull S,int x,int y) {
    FOR(i,0,7) {
        if(pd(i,x+y-i)) {T|=1ull<<(i*8+x+y-i),tot+=in(S,(i*8+x+y-i));}
        if(pd(i,y-x+i)) {T|=1ull<<(i*8+y-x+i),tot+=in(S,(i*8+y-x+i));}
    }
}
void ban_horse(ull &tot,ull &T,ull S,int x,int y) {
    for(auto i:{-2,2}) for(auto j:{-1,1}) {
        if(pd(x+i,y+j)) T|=1ull<<((x+i)*8+(y+j)),tot+=in(S,((x+i)*8+(y+j)));
        if(pd(x+j,y+i)) T|=1ull<<((x+j)*8+(y+i)),tot+=in(S,((x+j)*8+(y+i)));
    }
}
void debug(ull S) {
    FOR(i,0,7) {
        FOR(j,0,7) cout<<in(S,i*8+j);
        cout<<"\n";
    }cout<<"\n";
}
int sg(ull S,ull ban,int now) {
    if(mp[now].count({S,ban})) return mp[now][{S,ban}];
    FOR(i,0,7) FOR(j,0,7) if(in(S,i*8+j)==0) {
        ull T=S|(1ull<<(i*8+j)),tot=0;
        if(s[now]=='B') ban_xiang(tot,T,ban,i,j);
        if(s[now]=='R') ban_car(tot,T,ban,i,j);
        if(s[now]=='Q') ban_car(tot,T,ban,i,j),  ban_xiang(tot,T,ban,i,j);
        if(s[now]=='A') ban_xiang(tot,T,ban,i,j),ban_horse(tot,T,ban,i,j);
        if(s[now]=='C') ban_car(tot,T,ban,i,j),  ban_horse(tot,T,ban,i,j);
        if(s[now]=='M') ban_car(tot,T,ban,i,j),  ban_xiang(tot,T,ban,i,j),ban_horse(tot,T,ban,i,j);
        if(tot) continue;
        if(sg(T,ban|(1ull<<(i*8+j)),now+1)==0) return mp[now][{S,ban}]=1,1;
    }
    return mp[now][{S,ban}]=0,0;
}
signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>s;
    if(sg(0,0,0)) cout<<"Alice\n";
    else cout<<"Bob\n";
    return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 157ms
memory: 17812kb

input:

BBAARRCCQQMM

output:

Bob

result:

ok single line: 'Bob'

Test #2:

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

input:

BAMBAMQQRCCR

output:

Alice

result:

ok single line: 'Alice'

Test #3:

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

input:

QQRAACMRMCBB

output:

Alice

result:

ok single line: 'Alice'

Test #4:

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

input:

MBBARQRMACQC

output:

Alice

result:

ok single line: 'Alice'

Test #5:

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

input:

ACQCMQRBBRMA

output:

Alice

result:

ok single line: 'Alice'

Test #6:

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

input:

MRCMABRQCQAB

output:

Alice

result:

ok single line: 'Alice'

Test #7:

score: 0
Accepted
time: 20ms
memory: 5668kb

input:

BBRCMMQAAQRC

output:

Alice

result:

ok single line: 'Alice'

Test #8:

score: 0
Accepted
time: 14ms
memory: 5492kb

input:

RRMCQMACABQB

output:

Alice

result:

ok single line: 'Alice'

Test #9:

score: 0
Accepted
time: 17ms
memory: 5696kb

input:

QMQBMRBACACR

output:

Alice

result:

ok single line: 'Alice'

Test #10:

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

input:

CMRQAQCBBRAM

output:

Alice

result:

ok single line: 'Alice'

Test #11:

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

input:

CABCRQMMRQAB

output:

Alice

result:

ok single line: 'Alice'

Test #12:

score: 0
Accepted
time: 67ms
memory: 9816kb

input:

ARCBBCMQRAQM

output:

Alice

result:

ok single line: 'Alice'

Test #13:

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

input:

ARCMCARMQBBQ

output:

Alice

result:

ok single line: 'Alice'

Test #14:

score: 0
Accepted
time: 40ms
memory: 8016kb

input:

AQABMCQCMRRB

output:

Bob

result:

ok single line: 'Bob'

Test #15:

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

input:

ACMRABRQMCBQ

output:

Alice

result:

ok single line: 'Alice'

Test #16:

score: 0
Accepted
time: 55ms
memory: 9440kb

input:

CBARMBCQMQAR

output:

Bob

result:

ok single line: 'Bob'

Test #17:

score: 0
Accepted
time: 75ms
memory: 10044kb

input:

RBABRQMCAMQC

output:

Bob

result:

ok single line: 'Bob'

Test #18:

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

input:

MBCQBQARRMCA

output:

Alice

result:

ok single line: 'Alice'

Test #19:

score: 0
Accepted
time: 30ms
memory: 7288kb

input:

AMBQRBCQACMR

output:

Bob

result:

ok single line: 'Bob'

Test #20:

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

input:

QRAMQMBBCRAC

output:

Alice

result:

ok single line: 'Alice'

Test #21:

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

input:

ARBCQMMBARQC

output:

Alice

result:

ok single line: 'Alice'

Test #22:

score: 0
Accepted
time: 106ms
memory: 14516kb

input:

CACAMBRQQRBM

output:

Bob

result:

ok single line: 'Bob'

Test #23:

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

input:

CQRRMMBQABCA

output:

Bob

result:

ok single line: 'Bob'

Test #24:

score: 0
Accepted
time: 36ms
memory: 7332kb

input:

ABABCQRMMCRQ

output:

Alice

result:

ok single line: 'Alice'

Test #25:

score: 0
Accepted
time: 23ms
memory: 5948kb

input:

CMBRAAQRQMBC

output:

Bob

result:

ok single line: 'Bob'

Test #26:

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

input:

AQBMRMQRBACC

output:

Alice

result:

ok single line: 'Alice'

Test #27:

score: 0
Accepted
time: 28ms
memory: 6472kb

input:

BRACQQMCAMBR

output:

Bob

result:

ok single line: 'Bob'

Test #28:

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

input:

MCCAQBMQRABR

output:

Bob

result:

ok single line: 'Bob'

Test #29:

score: 0
Accepted
time: 56ms
memory: 9444kb

input:

RBQBCRAACMQM

output:

Bob

result:

ok single line: 'Bob'

Test #30:

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

input:

ACRQARMBBQMC

output:

Bob

result:

ok single line: 'Bob'

Test #31:

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

input:

MRCQBCBQRMAA

output:

Alice

result:

ok single line: 'Alice'

Test #32:

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

input:

ACRQQCMMBBAR

output:

Bob

result:

ok single line: 'Bob'

Test #33:

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

input:

MMACQBRQABRC

output:

Bob

result:

ok single line: 'Bob'

Test #34:

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

input:

QACMQABRMCBR

output:

Alice

result:

ok single line: 'Alice'

Test #35:

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

input:

ACAQRCMRMBQB

output:

Alice

result:

ok single line: 'Alice'

Test #36:

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

input:

RABQCQMCABMR

output:

Bob

result:

ok single line: 'Bob'

Test #37:

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

input:

QQBARCRBMMAC

output:

Alice

result:

ok single line: 'Alice'

Test #38:

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

input:

RQMRQABCABCM

output:

Alice

result:

ok single line: 'Alice'

Test #39:

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

input:

RQAMBRQCCBMA

output:

Alice

result:

ok single line: 'Alice'

Test #40:

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

input:

QQBACMARMRBC

output:

Alice

result:

ok single line: 'Alice'

Test #41:

score: 0
Accepted
time: 14ms
memory: 5820kb

input:

QAQCRRAMMCBB

output:

Alice

result:

ok single line: 'Alice'

Test #42:

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

input:

QQBMCBRARMAC

output:

Bob

result:

ok single line: 'Bob'

Test #43:

score: 0
Accepted
time: 119ms
memory: 14872kb

input:

BABARRCCQQMM

output:

Bob

result:

ok single line: 'Bob'

Test #44:

score: 0
Accepted
time: 652ms
memory: 51804kb

input:

BBARARCCQQMM

output:

Alice

result:

ok single line: 'Alice'

Test #45:

score: 0
Accepted
time: 68ms
memory: 10324kb

input:

BBAARCRCQQMM

output:

Alice

result:

ok single line: 'Alice'

Test #46:

score: 0
Accepted
time: 215ms
memory: 21624kb

input:

BBAARRCQCQMM

output:

Bob

result:

ok single line: 'Bob'

Test #47:

score: 0
Accepted
time: 151ms
memory: 17760kb

input:

BBAARRCCQMQM

output:

Bob

result:

ok single line: 'Bob'

Test #48:

score: 0
Accepted
time: 471ms
memory: 41972kb

input:

BBAACCRQMQRM

output:

Bob

result:

ok single line: 'Bob'

Test #49:

score: 0
Accepted
time: 649ms
memory: 54716kb

input:

BACBACQRRQMM

output:

Bob

result:

ok single line: 'Bob'

Test #50:

score: 0
Accepted
time: 1568ms
memory: 112672kb

input:

RAABBRCCQQMM

output:

Bob

result:

ok single line: 'Bob'

Test #51:

score: 0
Accepted
time: 117ms
memory: 12816kb

input:

RABRBQMCACQM

output:

Bob

result:

ok single line: 'Bob'

Test #52:

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

input:

CMMQQABCRABR

output:

Alice

result:

ok single line: 'Alice'

Test #53:

score: 0
Accepted
time: 267ms
memory: 27324kb

input:

RBAABRCCQQMM

output:

Alice

result:

ok single line: 'Alice'

Extra Test:

score: 0
Extra Test Passed