QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#230178 | #7635. Fairy Chess | ucup-team191# | WA | 0ms | 3748kb | C++14 | 1.8kb | 2023-10-28 17:48:38 | 2023-10-28 17:48:38 |
Judging History
answer
#include <bits/stdc++.h>
#define x first
#define y second
using namespace std;
using pii=pair<int,int>;
using vi=vector<int>;
using ll=long long;
using ull=unsigned long long;
using vl=vector<ll>;
#define pb push_back
#define all(a) begin(a),end(a)
const int N=310,MOD=1e9+7;
const char en='\n';
const ll LLINF=1ll<<60;
int n;
string s;
ull bi[N][N];
unordered_map<ull,bool> mem[N];
bool pob(int i,ull ma)
{
if (ma+1==0) return 0;
if (mem[i].find(ma)!=mem[i].end()) return mem[i][ma];
for (int p=0;p<64;++p) if ((ma&bi[s[i]][p])==0 && pob(i+1,ma|bi[s[i]][p])==0) return mem[i][ma]=1;
return mem[i][ma]=0;
}
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
cin>>s;
for (int i=0;i<8;++i) for (int j=0;j<8;++j)
{
for (int i1=0;i1<8;++i1) for (int j1=0;j1<8;++j1)
{
if (i1+j1==i+j || i1-j1==i-j)
{
bi['B'][i*8+j]|=1ull<<(i1*8+j1);
bi['A'][i*8+j]|=1ull<<(i1*8+j1);
bi['Q'][i*8+j]|=1ull<<(i1*8+j1);
bi['M'][i*8+j]|=1ull<<(i1*8+j1);
}
if (i1==i || j1==j)
{
bi['Q'][i*8+j]|=1ull<<(i1*8+j1);
bi['M'][i*8+j]|=1ull<<(i1*8+j1);
bi['R'][i*8+j]|=1ull<<(i1*8+j1);
bi['C'][i*8+j]|=1ull<<(i1*8+j1);
}
int d1=abs(i1-i),d2=abs(j1-j);
if ((d1==1 && d2==2) || (d1==2 && d2==1))
{
bi['A'][i*8+j]|=1ull<<(i1*8+j1);
bi['M'][i*8+j]|=1ull<<(i1*8+j1);
bi['C'][i*8+j]|=1ull<<(i1*8+j1);
bi['K'][i*8+j]|=1ull<<(i1*8+j1);
}
}
}
/*ull re=bi['K'][18];
for (int i=0;i<8;++i,cout<<en) for (int j=0;j<8;++j) cout<<((re>>(i*8+j))&1);
cout<<en;
re=bi['B'][18];
for (int i=0;i<8;++i,cout<<en) for (int j=0;j<8;++j) cout<<((re>>(i*8+j))&1);
cout<<en;
re=bi['R'][18];
for (int i=0;i<8;++i,cout<<en) for (int j=0;j<8;++j) cout<<((re>>(i*8+j))&1);*/
if (pob(0,0)) cout<<"Alice\n";
else cout<<"Bob\n";
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3536kb
input:
BBAARRCCQQMM
output:
Bob
result:
ok single line: 'Bob'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3748kb
input:
BAMBAMQQRCCR
output:
Alice
result:
ok single line: 'Alice'
Test #3:
score: 0
Accepted
time: 0ms
memory: 3572kb
input:
QQRAACMRMCBB
output:
Alice
result:
ok single line: 'Alice'
Test #4:
score: 0
Accepted
time: 0ms
memory: 3672kb
input:
MBBARQRMACQC
output:
Alice
result:
ok single line: 'Alice'
Test #5:
score: 0
Accepted
time: 0ms
memory: 3600kb
input:
ACQCMQRBBRMA
output:
Alice
result:
ok single line: 'Alice'
Test #6:
score: 0
Accepted
time: 0ms
memory: 3660kb
input:
MRCMABRQCQAB
output:
Alice
result:
ok single line: 'Alice'
Test #7:
score: -100
Wrong Answer
time: 0ms
memory: 3608kb
input:
BBRCMMQAAQRC
output:
Bob
result:
wrong answer 1st lines differ - expected: 'Alice', found: 'Bob'