QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#263694 | #7179. Fischer's Chess Guessing Game | sofija6 | AC ✓ | 35ms | 7728kb | C++23 | 2.5kb | 2023-11-25 03:25:17 | 2023-11-25 03:25:17 |
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;
}
bool Cmp(ll i,ll j)
{
return i>j;
}
void Solve(ll a)
{
for (ll i=0;i<v.size();i++)
{
if (same[ans][i]!=a)
ch[i]=false;
}
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] && i!=j)
continue;
cnt[same[i][j]]++;
m=max(m,cnt[same[i][j]]);
}
if (m<maxx)
{
ans=i;
maxx=m;
}
}
}
void Create(string s)
{
vector<ll> p;
set<string> ss;
ss.insert(s);
for (ll i=0;i<8;i++)
p.push_back(i);
while (next_permutation(p.begin(),p.end()))
{
string s1="........";
for (ll i=0;i<8;i++)
s1[i]=s[p[i]];
ll r=0,b=-1;
bool yes=true;
for (ll i=0;i<8;i++)
{
if (s1[i]=='K' && r!=1)
{
yes=false;
break;
}
if (s1[i]=='B' && b!=-1 && b==(i%2))
{
yes=false;
break;
}
if (s1[i]=='R')
r++;
if (s1[i]=='B' && b==-1)
b=(i%2);
}
if (yes && !ss.count(s1))
v.push_back(s1);
ss.insert(s1);
}
}
int main()
{
string x="";
ll ans0,a,n,maxx=1e6;
Create("KQRRBBNN");
ans0=0;
for (ll i=0;i<v.size();i++)
{
ll cur=0;
for (ll j=0;j<v.size();j++)
{
ll cnt=Num_Of_Same(i,j);
same[i][j]=cnt;
cur=max(cur,cnt);
}
if (v[i]=="NRBBNKQR")
ans0=i;
}
while (true)
{
cin >> x;
if (x=="END")
return 0;
cin >> n;
ans=ans0;
for (ll i=0;i<v.size();i++)
ch[i]=1;
ll cc=0;
while (true)
{
cc++;
if (cc>6)
return 0;
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: 11ms
memory: 7508kb
input:
GAME 1 1 2 2 4 8 END
output:
NRBBNKQR BNRKQBNR RNBQKRNB RKRQNBBN RKRBBQNN
result:
ok (c) correct after 1 tests, max moves 5 (1 test case)
Test #2:
score: 0
Accepted
time: 34ms
memory: 7512kb
input:
GAME 1 1 2 2 4 8 GAME 2 2 2 4 1 8 GAME 3 1 2 2 3 8 GAME 4 1 2 1 8 GAME 5 2 1 2 3 1 8 GAME 6 2 2 2 1 8 GAME 7 0 2 3 6 8 GAME 8 1 2 1 4 5 8 GAME 9 0 3 1 2 8 GAME 10 0 3 3 3 8 GAME 11 0 5 5 8 GAME 12 1 1 2 3 8 GAME 13 1 2 2 8 GAME 14 0 4 3 8 GAME 15 1 2 1 4 8 GAME 16 1 1 1 1 8 GAME 17 0 5 8 GAME 18 1 1...
output:
NRBBNKQR BNRKQBNR RNBQKRNB RKRQNBBN RKRBBQNN NRBBNKQR RBBQKNNR RKNNBBQR QRNKBBNR RKRBBNQN NRBBNKQR BNRKQBNR RNBQKRNB RKRQNBBN RKRBBNNQ NRBBNKQR BNRKQBNR RNBQKRNB RKRBQNBN NRBBNKQR RBBQKNNR BRKBQRNN NNRBKRBQ QNNBBRKR RKRBNQBN NRBBNKQR RBBQKNNR RKNNBBQR BBNRNQKR RKRBNNBQ NRBBNKQR RKNNRQBB RNKNBBRQ RKQ...
result:
ok (c) correct after 96 tests, max moves 6 (96 test cases)
Test #3:
score: 0
Accepted
time: 35ms
memory: 7712kb
input:
GAME 1 2 4 3 2 8 GAME 2 2 3 3 8 GAME 3 3 0 5 8 GAME 4 3 0 2 8 GAME 5 2 3 5 3 8 GAME 6 3 0 3 2 8 GAME 7 1 3 6 8 GAME 8 1 3 8 GAME 9 2 2 8 GAME 10 2 2 5 8 GAME 11 2 3 2 4 8 GAME 12 1 3 5 8 GAME 13 0 2 3 5 8 GAME 14 1 0 1 4 8 GAME 15 0 1 1 1 8 GAME 16 0 2 2 2 8 GAME 17 1 0 3 3 8 GAME 18 1 0 3 3 6 8 GAM...
output:
NRBBNKQR RBBQKNNR RQBBKRNN QNBRKBNR RKQBBNNR NRBBNKQR RBBQKNNR RKBBQNRN RKNBBQNR NRBBNKQR NRBQKBRN RBNNBKQR RKNBBNQR NRBBNKQR NRBQKBRN RBNNBKQR RKQBNNBR NRBBNKQR RBBQKNNR RKBBQNRN RKBBRQNN RKNBQNBR NRBBNKQR NRBQKBRN RBNNBKQR QNRBBKNR RKNBNQBR NRBBNKQR BNRKQBNR RKNQBBNR RKQNBBNR NRBBNKQR BNRKQBNR RKN...
result:
ok (c) correct after 96 tests, max moves 6 (96 test cases)
Test #4:
score: 0
Accepted
time: 35ms
memory: 7496kb
input:
GAME 1 1 2 1 1 8 GAME 2 3 4 3 1 8 GAME 3 2 1 3 8 GAME 4 1 1 3 8 GAME 5 2 1 3 6 8 GAME 6 3 2 0 4 2 8 GAME 7 2 0 1 8 GAME 8 2 0 0 8 GAME 9 3 3 0 2 8 GAME 10 2 1 2 1 8 GAME 11 2 1 3 4 4 8 GAME 12 3 2 1 3 8 GAME 13 2 1 6 5 8 GAME 14 3 2 0 8 GAME 15 2 2 0 4 4 8 GAME 16 1 3 3 1 4 8 GAME 17 2 0 2 1 8 GAME ...
output:
NRBBNKQR BNRKQBNR RNBQKRNB RKRBQNBN QRKRBBNN NRBBNKQR NRBQKBRN NRNQBKRB RBBQNKRN NRKRBBQN NRBBNKQR RBBQKNNR BRKBQRNN NRKRBBNQ NRBBNKQR BNRKQBNR RQKBBRNN QRKRBNNB NRBBNKQR RBBQKNNR BRKBQRNN NRKRBBNQ NRKRBQNB NRBBNKQR NRBQKBRN RBBNNKRQ BRKBRNQN BRQBKNNR NRKRBNQB NRBBNKQR RBBQKNNR BQRNNKRB QRKRNBBN NRB...
result:
ok (c) correct after 96 tests, max moves 6 (96 test cases)
Test #5:
score: 0
Accepted
time: 32ms
memory: 7488kb
input:
GAME 1 0 4 1 8 GAME 2 0 3 4 2 8 GAME 3 0 4 1 6 8 GAME 4 0 5 4 8 GAME 5 0 4 3 2 8 GAME 6 0 6 4 4 8 GAME 7 1 3 2 4 8 GAME 8 3 2 4 3 8 GAME 9 2 4 4 5 8 GAME 10 0 1 3 8 GAME 11 1 1 4 4 8 GAME 12 0 2 3 3 8 GAME 13 1 1 3 0 8 GAME 14 0 3 2 1 8 GAME 15 1 1 2 3 1 8 GAME 16 2 3 2 1 8 GAME 17 1 4 2 1 8 GAME 18...
output:
NRBBNKQR RKNNRQBB RKQNBRNB RQNKRBBN NRBBNKQR RKNNRQBB QNRKRNBB QNNRKRBB RNQKRBBN NRBBNKQR RKNNRQBB RKQNBRNB RQNKRBBN RNNKRBBQ NRBBNKQR RKNNRQBB RKRNQNBB RQNKRNBB NRBBNKQR RKNNRQBB RKQNBRNB RKRNQBBN RNQKRNBB NRBBNKQR RKNNRQBB RKQNRNBB RKNNBQRB RNNKRQBB NRBBNKQR BNRKQBNR RKNQBBNR RNBKRQNB RBBKQRNN NRB...
result:
ok (c) correct after 96 tests, max moves 6 (96 test cases)
Test #6:
score: 0
Accepted
time: 32ms
memory: 7460kb
input:
GAME 1 3 5 8 GAME 2 3 6 8 GAME 3 4 1 6 8 GAME 4 3 3 2 8 GAME 5 3 4 4 2 8 GAME 6 4 1 8 GAME 7 1 2 0 8 GAME 8 2 0 1 3 4 8 GAME 9 2 0 1 2 4 8 GAME 10 1 1 1 5 8 GAME 11 2 1 1 0 6 8 GAME 12 2 0 2 4 3 8 GAME 13 3 2 1 5 8 GAME 14 2 2 3 1 3 8 GAME 15 4 3 2 3 8 GAME 16 4 4 4 2 8 GAME 17 4 3 3 2 8 GAME 18 6 4...
output:
NRBBNKQR NRBQKBRN QRBKNBRN NRBBNKQR NRBQKBRN NRBKQBRN NRBBNKQR QRNBBKNR NRBKNQRB NRBKNBRQ NRBBNKQR NRBQKBRN RNBBQKRN QRBKNNRB NRBBNKQR NRBQKBRN NRNQBKRB NRKQBBNR NRBKQNRB NRBBNKQR QRNBBKNR NRBKNQRB NRBBNKQR BNRKQBNR RNBQKRNB QRNKBBRN NRBBNKQR RBBQKNNR BQRNNKRB QRKRNBBN BRNKRBQN NRQKBBRN NRBBNKQR RBB...
result:
ok (c) correct after 96 tests, max moves 6 (96 test cases)
Test #7:
score: 0
Accepted
time: 34ms
memory: 7720kb
input:
GAME 1 1 1 4 3 2 8 GAME 2 2 4 5 8 GAME 3 1 1 3 1 2 8 GAME 4 0 3 1 6 8 GAME 5 0 3 1 5 8 GAME 6 0 4 3 3 8 GAME 7 2 4 8 GAME 8 3 3 5 3 8 GAME 9 2 4 6 4 8 GAME 10 1 1 4 2 8 GAME 11 1 2 8 GAME 12 2 3 2 3 8 GAME 13 1 0 4 2 4 8 GAME 14 1 1 4 5 8 GAME 15 1 1 3 0 3 8 GAME 16 0 5 4 5 8 GAME 17 0 4 5 8 GAME 18...
output:
NRBBNKQR BNRKQBNR RQKBBRNN RKNBQRBN RQKRNBBN RBBQKRNN NRBBNKQR RBBQKNNR RQBBKRNN RBBNKRQN NRBBNKQR BNRKQBNR RQKBBRNN QRKRBNNB RQNKNRBB RBBNKRNQ NRBBNKQR RKNNRQBB QNRKRNBB RBKNQRBN RBQNKRBN NRBBNKQR RKNNRQBB QNRKRNBB RBKNQRBN RBNQKRBN NRBBNKQR RKNNRQBB RKQNBRNB RKRNQBBN RBNNKRBQ NRBBNKQR RBBQKNNR RQB...
result:
ok (c) correct after 96 tests, max moves 6 (96 test cases)
Test #8:
score: 0
Accepted
time: 34ms
memory: 7680kb
input:
GAME 1 3 2 0 3 8 GAME 2 4 3 1 6 8 GAME 3 4 4 4 5 8 GAME 4 2 2 4 5 8 GAME 5 3 4 2 5 8 GAME 6 3 5 2 4 8 GAME 7 0 0 5 2 8 GAME 8 1 2 2 2 2 8 GAME 9 0 1 4 1 8 GAME 10 1 3 1 0 8 GAME 11 2 1 4 2 1 8 GAME 12 1 4 3 4 3 8 GAME 13 0 2 1 4 8 GAME 14 0 1 6 5 8 GAME 15 1 3 0 4 3 8 GAME 16 0 2 1 8 GAME 17 1 1 2 2...
output:
NRBBNKQR NRBQKBRN RBBNNKRQ BRKBRNQN QRNBKNBR NRBBNKQR QRNBBKNR RBBQNKNR NRKBQNBR NRQBKNBR NRBBNKQR QRNBBKNR NRNKBBQR BRNBKNQR NRNBKQBR NRBBNKQR RBBQKNNR RKNNBBQR QRNKBBNR QRNNKBBR NRBBNKQR NRBQKBRN NRNQBKRB NRQBKRBN NRQNKBBR NRBBNKQR NRBQKBRN QRBKNBRN NRBQKRNB NRNQKBBR NRBBNKQR RKNNRQBB QBRKBRNN QNR...
result:
ok (c) correct after 96 tests, max moves 6 (96 test cases)
Test #9:
score: 0
Accepted
time: 25ms
memory: 7728kb
input:
GAME 1 2 6 8 GAME 2 3 3 1 4 8 GAME 3 4 1 2 3 8 GAME 4 1 1 0 2 8 GAME 5 2 4 1 5 3 8 GAME 6 2 3 0 2 3 8 GAME 7 2 4 3 8 GAME 8 3 4 1 3 8 GAME 9 4 1 2 4 8 GAME 10 1 3 3 8 GAME 11 2 2 3 2 0 8 GAME 12 2 2 2 2 2 8 GAME 13 3 4 3 8 GAME 14 2 3 5 3 2 8 GAME 15 3 2 8 GAME 16 1 0 1 5 8 GAME 17 1 0 3 2 8 GAME 18...
output:
NRBBNKQR RBBQKNNR QBBRKNNR NRBBNKQR NRBQKBRN RNBBQKRN NBBQRNKR NBBRKQNR NRBBNKQR QRNBBKNR NRBKNQRB RKBNNBQR NBBRKNQR NRBBNKQR BNRKQBNR RQKBBRNN BRQNKNRB QBNRKNBR NRBBNKQR RBBQKNNR RQBBKRNN BBNRKNQR RBNKBNQR NBQRKNBR NRBBNKQR RBBQKNNR RKBBQNRN QBRNBKNR BBNQNRKR NBNRKQBR NRBBNKQR RBBQKNNR RQBBKRNN QNB...
result:
ok (c) correct after 96 tests, max moves 6 (96 test cases)
Test #10:
score: 0
Accepted
time: 24ms
memory: 7508kb
input:
GAME 1 3 1 2 3 8 GAME 2 2 3 1 3 8 GAME 3 4 2 2 8 GAME 4 4 4 1 5 8 GAME 5 3 0 2 2 8 GAME 6 5 4 3 8 GAME 7 2 3 0 8 GAME 8 3 2 2 1 0 8 GAME 9 4 3 3 1 8 GAME 10 3 0 4 8 GAME 11 4 2 2 5 8 GAME 12 3 1 3 2 4 8 GAME 13 3 0 3 8 GAME 14 4 5 3 8 GAME 15 5 3 3 2 8 GAME 16 4 4 1 8 GAME 17 5 5 3 4 8 GAME 18 4 3 2...
output:
NRBBNKQR NRBQKBRN NQRBBNKR QBBNNRKR BBRQNKNR NRBBNKQR RBBQKNNR RKBBQNRN QBRKNNBR BBRNQKNR NRBBNKQR QRNBBKNR RNBBNKRQ BBRNNKQR NRBBNKQR QRNBBKNR NRNKBBQR QNRBNKBR BQRBNKNR NRBBNKQR NRBQKBRN RBNNBKQR RKQBNNBR BNRBQKNR NRBBNKQR RQBBNKNR QRBBNNKR BNRBNKQR NRBBNKQR RBBQKNNR RKBBQNRN QBRNBKNR NRBBNKQR NRB...
result:
ok (c) correct after 96 tests, max moves 6 (96 test cases)
Test #11:
score: 0
Accepted
time: 20ms
memory: 7520kb
input:
GAME 1 2 3 3 5 8 GAME 2 2 3 3 4 1 8 GAME 3 2 2 4 3 8 GAME 4 1 2 1 1 2 8 GAME 5 1 3 4 8 GAME 6 1 3 6 4 8 GAME 7 4 3 2 5 8 GAME 8 3 1 4 5 8 GAME 9 4 4 3 8 GAME 10 3 2 2 2 1 8 GAME 11 3 3 0 5 8 GAME 12 2 1 3 2 0 8 GAME 13 5 4 8 GAME 14 5 3 4 8 GAME 15 6 5 4 5 8 GAME 16 4 3 3 5 8 GAME 17 5 3 3 8 GAME 18...
output:
NRBBNKQR RBBQKNNR RKBBQNRN RKNBBQNR RQNBBNKR NRBBNKQR RBBQKNNR RKBBQNRN RKNBBQNR RKBRNQNB RNQBBNKR NRBBNKQR RBBQKNNR RKNNBBQR QRNKBBNR RNNBBQKR NRBBNKQR BNRKQBNR RNBQKRNB RKRBQNBN QRKRBBNN RQNNBBKR NRBBNKQR BNRKQBNR RKNQBBNR RNQNBBKR NRBBNKQR BNRKQBNR RKNQBBNR RKQNBBNR RNNQBBKR NRBBNKQR QRNBBKNR RBB...
result:
ok (c) correct after 96 tests, max moves 6 (96 test cases)
Extra Test:
score: 0
Extra Test Passed