QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#168850 | #7179. Fischer's Chess Guessing Game | Forever_Young# | AC ✓ | 34ms | 7532kb | C++14 | 1.9kb | 2023-09-08 23:54:16 | 2023-09-08 23:54:16 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
char ch[960][9],s[9];
int cnt,f[960],nowf,num[960][9],q,n,b,r,k,qu[960][960],itask,iask;
void dfs(int x){
if (x==8){
for (int i=0;i<8;i++) ch[cnt][i]=s[i];
cnt++;
return;
}
//Queen
if (q==0){
s[x]='Q';
q=1;
dfs(x+1);
q=0;
}
//kNight
if (n<2){
s[x]='N';
n++;
dfs(x+1);
n--;
}
//Bishop
if (b==-1){
s[x]='B';
b=x;
dfs(x+1);
b=-1;
}
else if (b>=0&&((b&1)!=(x&1))){
int tmp=b;
s[x]='B';
b=-2;
dfs(x+1);
b=tmp;
}
//Rook
if (r==0){
s[x]='R';
r=1;
dfs(x+1);
r=0;
}
else if (r==1&&k==1){
s[x]='R';
r=2;
dfs(x+1);
r=1;
}
//King
if (r==1&&k==0){
s[x]='K';
k=1;
dfs(x+1);
k=0;
}
}
int ask(){
int res,ma;
res=0; ma=cnt;
for (int i=0;i<cnt;i++)
for (int j=0;j<=8;j++) num[i][j]=0;
for (int i=0;i<cnt;i++)
if (f[i]){
for (int j=0;j<cnt;j++) num[j][qu[i][j]]+=1;
}
for (int i=0;i<cnt;i++){
int tmp=0;
for (int j=0;j<=8;j++) tmp=max(tmp,num[i][j]);
if (tmp<ma){
ma=tmp;
res=i;
}
}
return res;
}
void work(){
int tmp;
scanf("%d",&tmp);
for (int i=0;i<cnt;i++) f[i]=1;
itask=iask;
while (true){
printf("%s\n",ch[itask]);
fflush(stdout);
scanf("%d",&tmp);
if (tmp==8) return;
nowf=0;
for (int i=0;i<cnt;i++)
if (f[i]&&qu[i][itask]==tmp){
f[i]=1;
nowf++;
}
else f[i]=0;
if (nowf==1) break;
itask=ask();
}
for (int i=0;i<cnt;i++)
if (f[i]){
printf("%s\n",ch[i]);
fflush(stdout);
scanf("%d\n",&tmp);
break;
}
return;
}
int main(){
b=-1;
dfs(0);
for (int i=0;i<cnt;i++)
for (int j=0;j<cnt;j++){
for (int k=0;k<8;k++)
if (ch[i][k]==ch[j][k])
qu[i][j]++;
}
for (int i=0;i<cnt;i++) f[i]=1;
iask=ask();
scanf("%s",s);
while (s[0]=='G'){
work();
scanf("%s",s);
}
/*
for (int i=0;i<6;){
}
fflush(stdout);
scanf("");
*/
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 14ms
memory: 7532kb
input:
GAME 1 2 4 1 1 8 END
output:
NRNBBKQR RNQBBKRN QNNRBBKR QNBBNRKR RKRBBQNN
result:
ok (c) correct after 1 tests, max moves 5 (1 test case)
Test #2:
score: 0
Accepted
time: 28ms
memory: 7528kb
input:
GAME 1 2 4 1 1 8 GAME 2 3 5 4 8 GAME 3 2 3 3 2 2 8 GAME 4 1 0 3 1 2 8 GAME 5 1 0 4 2 0 8 GAME 6 1 0 3 1 1 8 GAME 7 1 3 2 1 1 8 GAME 8 2 3 1 1 1 8 GAME 9 1 4 0 0 8 GAME 10 1 2 3 2 8 GAME 11 1 3 1 2 1 8 GAME 12 2 2 1 2 0 8 GAME 13 0 2 5 4 8 GAME 14 0 3 1 2 8 GAME 15 0 2 4 3 8 GAME 16 0 1 1 5 8 GAME 17...
output:
NRNBBKQR RNQBBKRN QNNRBBKR QNBBNRKR RKRBBQNN NRNBBKQR RQKBBNRN BNRBKRQN RKRBBNQN NRNBBKQR RNQBBKRN RQNBKNBR QRNKBNRB QNNBBRKR RKRBBNNQ NRNBBKQR QRKNBBNR QBRKNRBN QNNRKRBB QNBBRKRN RKRBQNBN NRNBBKQR QRKNBBNR QBRKNRBN QNBBNRKR QNBNRKRB RKRBNQBN NRNBBKQR QRKNBBNR QBRKNRBN QNNRKRBB QNBBRKRN RKRBNNBQ NRN...
result:
ok (c) correct after 96 tests, max moves 6 (96 test cases)
Test #3:
score: 0
Accepted
time: 28ms
memory: 7412kb
input:
GAME 1 3 4 3 3 8 GAME 2 4 2 2 3 8 GAME 3 5 4 4 8 GAME 4 2 3 5 2 8 GAME 5 3 3 4 2 3 8 GAME 6 3 2 4 1 8 GAME 7 2 3 2 1 1 8 GAME 8 3 2 2 1 3 8 GAME 9 4 2 0 2 8 GAME 10 1 3 4 4 1 8 GAME 11 2 1 3 1 2 8 GAME 12 2 1 2 3 2 8 GAME 13 1 3 0 1 1 8 GAME 14 2 3 2 2 1 8 GAME 15 1 3 0 2 1 8 GAME 16 0 2 5 1 8 GAME ...
output:
NRNBBKQR RQKBBNRN QNRBKNBR QNNBBRKR RKQBBNNR NRNBBKQR BNRBNKQR QRBBKRNN QNNRBBKR RKNBBQNR NRNBBKQR BQNBRNKR QNRBBNKR RKNBBNQR NRNBBKQR RNQBBKRN RQNBKNBR QNNBBRKR RKQBNNBR NRNBBKQR RQKBBNRN QRKBNNBR QBBRNNKR QNNBBRKR RKNBQNBR NRNBBKQR RQKBBNRN BRKBNQNR QNBNRBKR RKNBNQBR NRNBBKQR RNQBBKRN RQNBKNBR BRK...
result:
ok (c) correct after 96 tests, max moves 6 (96 test cases)
Test #4:
score: 0
Accepted
time: 27ms
memory: 7532kb
input:
GAME 1 2 2 1 0 1 8 GAME 2 4 1 3 3 1 8 GAME 3 3 2 3 0 1 8 GAME 4 2 1 1 3 1 8 GAME 5 3 2 4 0 1 8 GAME 6 4 1 4 2 8 GAME 7 1 4 4 4 8 GAME 8 2 1 3 2 3 8 GAME 9 2 0 2 3 0 8 GAME 10 1 3 3 1 1 8 GAME 11 2 0 2 5 8 GAME 12 2 0 2 4 0 8 GAME 13 2 2 3 0 8 GAME 14 3 4 2 1 8 GAME 15 2 1 2 0 2 8 GAME 16 1 4 4 1 8 G...
output:
NRNBBKQR RNQBBKRN RNBBKQNR BBRNNKRQ QNNBRKBR QRKRBBNN NRNBBKQR BNRBNKQR QRKNBRNB QNNRBBKR QNNBBRKR NRKRBBQN NRNBBKQR RQKBBNRN BRKBNQNR QNNBRKBR QNNBBRKR NRKRBBNQ NRNBBKQR RNQBBKRN BRNQKBRN QRNKNRBB QNNBRKBR QRKRBNNB NRNBBKQR RQKBBNRN BRKBNQNR QNBNRBKR QNNBBRKR NRKRBQNB NRNBBKQR BNRBNKQR QRKNBRNB QNN...
result:
ok (c) correct after 96 tests, max moves 6 (96 test cases)
Test #5:
score: 0
Accepted
time: 21ms
memory: 7452kb
input:
GAME 1 1 1 3 6 8 GAME 2 0 1 1 4 8 GAME 3 1 1 2 2 2 8 GAME 4 1 0 2 6 8 GAME 5 0 0 1 2 8 GAME 6 1 0 2 5 8 GAME 7 0 2 2 1 0 8 GAME 8 1 0 5 3 8 GAME 9 0 1 4 1 8 GAME 10 1 2 1 0 8 GAME 11 3 3 0 0 3 8 GAME 12 2 2 2 6 1 8 GAME 13 0 2 4 2 8 GAME 14 1 0 5 1 2 8 GAME 15 1 0 5 2 2 8 GAME 16 0 0 4 1 8 GAME 17 0...
output:
NRNBBKQR QRKNBBNR NQNRKRBB QRNKRBBN RQNKRBBN NRNBBKQR BBRNKQRN NRBKQRNB RKQNRNBB RNQKRBBN NRNBBKQR QRKNBBNR NQNRKRBB QNRBKRBN QNNRBKRB RNNKRBBQ NRNBBKQR QRKNBBNR QBRKNRBN QRNKRNBB RQNKRNBB NRNBBKQR BBRNKQRN QRBKNBNR QRKNNRBB RNQKRNBB NRNBBKQR QRKNBBNR QBRKNRBN QRNKRNBB RNNKRQBB NRNBBKQR BBRNKQRN RQK...
result:
ok (c) correct after 96 tests, max moves 6 (96 test cases)
Test #6:
score: 0
Accepted
time: 25ms
memory: 7408kb
input:
GAME 1 1 3 4 2 2 8 GAME 2 2 2 1 1 0 8 GAME 3 2 1 3 0 0 8 GAME 4 1 2 2 3 1 8 GAME 5 2 1 2 1 0 8 GAME 6 2 1 2 2 0 8 GAME 7 3 3 2 3 4 8 GAME 8 3 3 1 1 8 GAME 9 4 0 3 8 GAME 10 3 3 3 3 3 8 GAME 11 3 3 2 0 0 8 GAME 12 4 0 2 8 GAME 13 2 1 3 0 1 8 GAME 14 3 0 4 1 3 8 GAME 15 4 4 4 2 8 GAME 16 2 0 4 4 2 8 G...
output:
NRNBBKQR QRKNBBNR QNRKNBBR QNRNKBBR QNNRBKRB QRBKNBRN NRNBBKQR RNQBBKRN RNBBKQNR BBRNNKRQ QNNBBRKR NRBKQBRN NRNBBKQR RNQBBKRN BRNQKBRN QNRBKRBN QNNBBRKR NRBKNBRQ NRNBBKQR QRKNBBNR BBRQNNKR QNBBNRKR QNNBBRKR QRBKNNRB NRNBBKQR RNQBBKRN BRNQKBRN QNRKNBBR QNNBBRKR NRBKQNRB NRNBBKQR RNQBBKRN BRNQKBRN QNR...
result:
ok (c) correct after 96 tests, max moves 6 (96 test cases)
Test #7:
score: 0
Accepted
time: 30ms
memory: 7492kb
input:
GAME 1 0 3 2 3 8 GAME 2 1 1 2 3 2 8 GAME 3 0 3 2 2 8 GAME 4 0 4 1 2 8 GAME 5 1 0 4 1 2 8 GAME 6 1 1 4 1 8 GAME 7 1 1 3 1 1 8 GAME 8 2 4 1 4 8 GAME 9 1 1 2 4 2 8 GAME 10 0 2 2 3 1 8 GAME 11 0 1 4 4 8 GAME 12 1 1 3 0 3 8 GAME 13 2 3 6 8 GAME 14 1 0 3 4 3 8 GAME 15 2 3 5 4 8 GAME 16 1 1 6 2 2 8 GAME 17...
output:
NRNBBKQR BBRNKQRN BBRKNQNR QNRBKRBN RBBQKRNN NRNBBKQR QRKNBBNR NQNRKRBB QNRBKRBN QNBNRBKR RBBNKRQN NRNBBKQR BBRNKQRN BBRKNQNR QNRBKRBN RBBNKRNQ NRNBBKQR BBRNKQRN QNRKBRNB QNNRKBBR RBQNKRBN NRNBBKQR QRKNBBNR QBRKNRBN QNBBNRKR QNNBBRKR RBNQKRBN NRNBBKQR QRKNBBNR NQNRKRBB NQBRKBNR RBNNKRBQ NRNBBKQR QRK...
result:
ok (c) correct after 96 tests, max moves 6 (96 test cases)
Test #8:
score: 0
Accepted
time: 31ms
memory: 7472kb
input:
GAME 1 4 2 4 5 8 GAME 2 4 2 3 2 8 GAME 3 5 3 4 8 GAME 4 3 0 2 4 8 GAME 5 3 0 3 4 8 GAME 6 4 1 1 4 8 GAME 7 0 5 1 0 8 GAME 8 1 1 2 4 0 8 GAME 9 0 5 1 1 8 GAME 10 1 1 3 1 0 8 GAME 11 2 3 2 4 8 GAME 12 1 1 2 5 2 8 GAME 13 0 4 4 1 8 GAME 14 0 3 3 3 8 GAME 15 1 1 3 0 2 8 GAME 16 0 5 2 2 8 GAME 17 1 0 5 1...
output:
NRNBBKQR BNRBNKQR QRBBKRNN QNNBRKBR QRNBKNBR NRNBBKQR BNRBNKQR QRBBKRNN QNNBBRKR NRQBKNBR NRNBBKQR BQNBRNKR QNNBRKBR NRNBKQBR NRNBBKQR RQKBBNRN NRBKQBRN QRNKNRBB QRNNKBBR NRNBBKQR RQKBBNRN NRBKQBRN QNNRKBBR NRQNKBBR NRNBBKQR BNRBNKQR QRKNBRNB QNRNKBBR NRNQKBBR NRNBBKQR BBRNKQRN QNBRKNRB QNBNRBKR BBR...
result:
ok (c) correct after 96 tests, max moves 6 (96 test cases)
Test #9:
score: 0
Accepted
time: 22ms
memory: 7408kb
input:
GAME 1 1 3 2 5 2 8 GAME 2 2 0 4 2 1 8 GAME 3 3 1 1 2 1 8 GAME 4 2 0 5 3 8 GAME 5 2 1 1 1 4 8 GAME 6 3 0 1 3 8 GAME 7 1 4 0 3 8 GAME 8 2 0 3 3 1 8 GAME 9 3 0 3 5 2 8 GAME 10 2 1 3 4 4 8 GAME 11 3 1 2 2 8 GAME 12 2 2 3 3 2 8 GAME 13 1 0 3 0 2 8 GAME 14 1 1 0 3 0 8 GAME 15 1 1 0 5 8 GAME 16 2 6 1 1 8 G...
output:
NRNBBKQR QRKNBBNR QNRKNBBR QBNRBNKR QNNBBRKR QBBRKNNR NRNBBKQR RNQBBKRN QBBRNNKR QNBNRBKR QNNBBRKR NBBRKQNR NRNBBKQR RQKBBNRN QNNBBRKR QNRNKBBR QNNBRKBR NBBRKNQR NRNBBKQR RNQBBKRN QBBRNNKR QNNRBKRB QBNRKNBR NRNBBKQR RNQBBKRN BRNQKBRN QRNKNRBB QNNRKBBR NBQRKNBR NRNBBKQR RQKBBNRN NRBKQBRN NQRBNKBR NBN...
result:
ok (c) correct after 96 tests, max moves 6 (96 test cases)
Test #10:
score: 0
Accepted
time: 30ms
memory: 7468kb
input:
GAME 1 2 1 2 3 1 8 GAME 2 2 1 1 0 1 8 GAME 3 3 0 0 2 8 GAME 4 3 2 5 3 8 GAME 5 3 1 3 2 8 GAME 6 4 8 GAME 7 3 1 3 5 8 GAME 8 4 3 2 3 8 GAME 9 5 1 2 8 GAME 10 2 1 0 4 3 8 GAME 11 3 0 1 6 8 GAME 12 3 0 2 1 8 GAME 13 4 5 5 5 8 GAME 14 5 3 3 8 GAME 15 6 4 3 8 GAME 16 3 1 4 4 6 8 GAME 17 4 5 4 8 GAME 18 4...
output:
NRNBBKQR RNQBBKRN BRNQKBRN QNRKNBBR QNNBBRKR BBRQNKNR NRNBBKQR RNQBBKRN BRNQKBRN QRNKNRBB QNNRBKRB BBRNQKNR NRNBBKQR RQKBBNRN NRBKQBRN QNNBRKBR BBRNNKQR NRNBBKQR RQKBBNRN BRKBNQNR QNBBNRKR BQRBNKNR NRNBBKQR RQKBBNRN QNNBBRKR NBRNBQKR BNRBQKNR NRNBBKQR BNRBNKQR NRNBBKQR RQKBBNRN QNNBBRKR NBRNBQKR QBR...
result:
ok (c) correct after 96 tests, max moves 6 (96 test cases)
Test #11:
score: 0
Accepted
time: 34ms
memory: 7472kb
input:
GAME 1 4 2 1 5 8 GAME 2 3 4 4 5 8 GAME 3 4 3 3 6 8 GAME 4 3 3 1 3 8 GAME 5 2 4 5 8 GAME 6 3 2 1 4 8 GAME 7 3 2 5 4 8 GAME 8 4 3 3 4 8 GAME 9 4 4 5 2 8 GAME 10 2 1 3 0 2 8 GAME 11 3 0 2 3 8 GAME 12 3 0 3 3 8 GAME 13 3 2 4 4 4 8 GAME 14 4 2 3 3 8 GAME 15 4 3 6 8 GAME 16 2 0 5 1 3 8 GAME 17 3 0 4 4 8 G...
output:
NRNBBKQR BNRBNKQR QRBBKRNN QNNBBRKR RQNBBNKR NRNBBKQR RQKBBNRN QNRBKNBR QNNBBRKR RNQBBNKR NRNBBKQR BNRBNKQR NQBBNRKR QNNBBRKR RNNBBQKR NRNBBKQR RQKBBNRN QRKBNNBR RKNQBRNB RQNNBBKR NRNBBKQR RNQBBKRN QNNRBBKR RNQNBBKR NRNBBKQR RQKBBNRN BRKBNQNR QBNRBNKR RNNQBBKR NRNBBKQR RQKBBNRN BRKBNQNR QNBBNRKR BRQ...
result:
ok (c) correct after 96 tests, max moves 6 (96 test cases)
Extra Test:
score: 0
Extra Test Passed