QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#254193 | #7179. Fischer's Chess Guessing Game | sofija6 | TL | 22ms | 7308kb | C++23 | 2.5kb | 2023-11-18 04:09:30 | 2023-11-18 04:09:31 |
Judging History
answer
#include <bits/stdc++.h>
#define ll int
#define MAXN 970
using namespace std;
vector<string> v;
bitset<MAXN> ch;
ll same[MAXN][MAXN],ans;
ll Num_Of_Same(ll i,ll j)
{
ll cnt=0;
for (ll l=0;l<8;l++)
cnt+=v[i][l]==v[j][l];
return cnt;
}
void Solve(ll a)
{
for (ll i=0;i<v.size();i++)
{
if (same[ans][i]!=a)
ch[i]=false;
}
if (ch.count()==1)
{
for (ll i=0;i<v.size();i++)
{
if (ch[i])
ans=i;
}
return;
}
ll maxx=1e6;
for (ll i=0;i<v.size();i++)
{
if (!ch[i])
continue;
ll cnt[10]={0},m=-1;
for (ll j=0;j<v.size();j++)
{
if (!ch[j])
continue;
cnt[same[i][j]]++;
m=max(m,cnt[same[i][j]]);
}
if (m<=maxx)
{
maxx=m;
ans=i;
}
}
}
ll b,p,k,n,q,r,prevv;
string s;
void Create()
{
if ((ll)s.size()==8)
{
v.push_back(s);
return;
}
if (!b || (b==1 && p!=s.size()%2))
{
b++;
prevv=p;
p=s.size()%2;
s+='B';
Create();
p=prevv;
b--;
s.pop_back();
}
if (!k && r==1)
{
s+='K';
k++;
Create();
k--;
s.pop_back();
}
if (n!=2)
{
s+='N';
n++;
Create();
n--;
s.pop_back();
}
if (!q)
{
s+='Q';
q++;
Create();
q--;
s.pop_back();
}
if (!r || (r==1 && k==1))
{
s+='R';
r++;
Create();
r--;
s.pop_back();
}
return;
}
int main()
{
string x="";
ll ans0,a;
Create();
for (ll i=0;i<v.size();i++)
{
if (v[i]=="NRBBNKQR")
ans0=i;
}
for (ll i=0;i<v.size();i++)
{
for (ll j=0;j<v.size();j++)
{
ll cnt=Num_Of_Same(i,j);
same[i][j]=cnt;
}
}
while (true)
{
cin >> x;
if (x=="END")
return 0;
cin >> n;
ans=ans0;
for (ll i=0;i<v.size();i++)
ch[i]=1;
while (true)
{
cout << v[ans] << "\n";
cin >> a;
if (a==8)
break;
Solve(a);
}
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 2ms
memory: 7308kb
input:
GAME 1 1 2 2 4 1 8 END
output:
NRBBNKQR BNRKQBNR RNBQKRNB RKRQNBBN RNKRNBBQ RKRBBQNN
result:
ok (c) correct after 1 tests, max moves 6 (1 test case)
Test #2:
score: 0
Accepted
time: 22ms
memory: 7236kb
input:
GAME 1 1 2 2 4 1 8 GAME 2 2 1 1 0 8 GAME 3 1 2 2 3 1 8 GAME 4 1 2 1 1 8 GAME 5 2 1 0 8 GAME 6 2 1 0 6 8 GAME 7 0 2 3 3 8 GAME 8 1 2 1 4 8 GAME 9 0 3 5 8 GAME 10 0 3 3 4 4 8 GAME 11 0 5 2 8 GAME 12 1 1 2 3 8 GAME 13 1 2 2 8 GAME 14 0 4 4 2 8 GAME 15 1 2 1 3 3 8 GAME 16 1 1 1 4 8 GAME 17 0 5 4 8 GAME ...
output:
NRBBNKQR BNRKQBNR RNBQKRNB RKRQNBBN RNKRNBBQ RKRBBQNN NRBBNKQR RNBNQBKR QRNNBKRB NBNRKQBR RKRBBNQN NRBBNKQR BNRKQBNR RNBQKRNB RKRQNBBN RQNNKBBR RKRBBNNQ NRBBNKQR BNRKQBNR RNBQKRNB RQNNBBKR RKRBQNBN NRBBNKQR RNBNQBKR QRNNBKRB RKRBNQBN NRBBNKQR RNBNQBKR QRNNBKRB RKRBNQBN RKRBNNBQ NRBBNKQR RKNNRQBB RNK...
result:
ok (c) correct after 96 tests, max moves 6 (96 test cases)
Test #3:
score: -100
Time Limit Exceeded
input:
GAME 1 2 2 2 8 GAME 2 2 2 1 2 2 8 GAME 3 3 0 5 5 8 GAME 4 3 0 2 6 5 8 GAME 5 2 3 2 3 8 GAME 6 3 0 3 2 8 GAME 7 1 3 6 8 GAME 8 1 3 5 4 8 GAME 9 2 4 3 5 3 8 GAME 10 2 4 3 8 GAME 11 2 3 1 4 8 GAME 12 1 3 4 3 2 8 GAME 13 0 2 3 5 8 GAME 14 1 0 1 5 8 GAME 15 0 1 1 1 8 GAME 16 0 2 2 8 GAME 17 1 0 3 3 8 GAM...
output:
NRBBNKQR RNBNQBKR NBRKQNBR RKQBBNNR NRBBNKQR RNBNQBKR NBRKQNBR RQBBKNRN RNKBNRBQ RKNBBQNR NRBBNKQR NRBQKBRN RBNNBKQR RQNBBKNR RKNBBNQR NRBBNKQR NRBQKBRN RBNNBKQR RQKBNNBR RNKBNQBR RKQBNNBR NRBBNKQR RNBNQBKR RNBBKQRN QNRBBNKR RKNBQNBR NRBBNKQR NRBQKBRN RBNNBKQR QNRBBKNR RKNBNQBR NRBBNKQR BNRKQBNR RQK...