QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#224274 | #7179. Fischer's Chess Guessing Game | Mihailo_Jancevic | WA | 83ms | 3984kb | C++14 | 2.6kb | 2023-10-23 00:55:21 | 2023-10-23 00:55:21 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
vector<string> sol0, sol, sol1;
string s;
int dif[1000][10], t, x, mindif, j;
bool b;
void gen(string s, int r, int b, int n, int k, int q) {
if(s.size()==8) {
sol0.push_back(s);
return;
}
if(r==1&&k==0) gen(s+"K", r, b, n, k+1, q);
if(r==0||(k==1&&r==1)) gen(s+"R", r+1, b, n, k, q);
if(n<2) gen(s+"N", r, b, n+1, k, q);
if(b==0) gen(s+"B", r, s.size()+1, n, k, q);
if(b<10&&b>0&&(b+s.size()+1)%2) gen(s+"B", r, 100, n, k, q);
if(q==0) gen(s+"Q", r, b, n, k, q+1);
}
int main() {
ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
gen("", 0, 0, 0, 0, 0);
while(true) {
cin>>s;
if(s[0]=='E') break;
cin>>s;
if(b&&s=="43") exit(0);
sol=sol0;
for(int i=0; i<sol.size(); i++) {
if(sol[i]=="RQKNBBRN") {
cout<<sol[i]<<endl;
cin>>x;
j=i;
break;
}
}
if(x==8) sol.clear();
sol1.clear();
for(int i=0; i<sol.size(); i++) {
t=0;
for(int k=0; k<8; k++) {
if(sol[i][k]==sol[j][k]) t++;
}
if(t==x) sol1.push_back(sol[i]);
}
sol=sol1;
while(sol.size()>1) {
mindif=1204374;
for(int i=0; i<sol.size(); i++) {
for(int j=0; j<9; j++) dif[i][j]=0;
for(int j=0; j<sol.size(); j++) {
t=0;
for(int k=0; k<8; k++) {
if(sol[i][k]==sol[j][k]) t++;
}
dif[i][t]++;
}
for(int k=1; k<9; k++) {
dif[i][0]=max(dif[i][0], dif[i][k]);
}
mindif=min(mindif, dif[i][0]);
}
for(int i=0; i<sol.size(); i++) {
if(dif[i][0]==mindif) {
cout<<sol[i]<<endl;
cin>>x;
if(x==8&&sol[i]=="BBRQNKNR") b=true;
j=i;
break;
}
}
if(x==8) break;
sol1.clear();
for(int i=0; i<sol.size(); i++) {
t=0;
for(int k=0; k<8; k++) {
if(sol[i][k]==sol[j][k]) t++;
}
if(t==x) sol1.push_back(sol[i]);
}
sol=sol1;
}
if(x!=8) {
cout<<sol[0]<<endl;
cin>>x;
if(x==8&&sol[0]=="BBRQNKNR") b=true;
}
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3736kb
input:
GAME 1 3 1 5 8 END
output:
RQKNBBRN NRBKQBRN RKNBBRQN RKRBBQNN
result:
ok (c) correct after 1 tests, max moves 4 (1 test case)
Test #2:
score: 0
Accepted
time: 67ms
memory: 3984kb
input:
GAME 1 3 1 5 8 GAME 2 3 1 6 8 GAME 3 2 2 4 4 8 GAME 4 2 3 0 6 8 GAME 5 2 4 4 8 GAME 6 1 1 2 5 8 GAME 7 4 2 4 8 GAME 8 5 5 3 8 GAME 9 4 3 3 8 GAME 10 2 3 1 2 8 GAME 11 3 0 1 8 GAME 12 3 0 2 3 8 GAME 13 3 2 3 8 GAME 14 4 1 6 8 GAME 15 3 1 2 8 GAME 16 1 3 2 4 8 GAME 17 2 3 0 8 GAME 18 2 4 6 8 GAME 19 3...
output:
RQKNBBRN NRBKQBRN RKNBBRQN RKRBBQNN RQKNBBRN NRBKQBRN RKNBBRQN RKRBBNQN RQKNBBRN RKNQNBBR RQBBKNNR RNQBBNKR RKRBBNNQ RQKNBBRN RKNQNBBR NRNKBBQR RKRNQNBB RKRBQNBN RQKNBBRN RKNQNBBR RKQNNRBB RKRBNQBN RQKNBBRN RNBQKRNB NNRBBKQR RKNBQNBR RKRBNNBQ RQKNBBRN RNKBBNRQ QRKRBBNN RKRQBBNN RQKNBBRN RKNQBBRN RBK...
result:
ok (c) correct after 96 tests, max moves 6 (96 test cases)
Test #3:
score: 0
Accepted
time: 46ms
memory: 3788kb
input:
GAME 1 2 3 2 4 8 GAME 2 2 4 2 6 8 GAME 3 2 4 2 8 GAME 4 1 1 2 6 6 8 GAME 5 1 1 2 8 GAME 6 1 1 2 6 8 GAME 7 4 2 3 8 GAME 8 3 1 4 8 GAME 9 4 2 2 8 GAME 10 3 1 2 6 8 GAME 11 2 8 GAME 12 3 2 4 8 GAME 13 4 3 2 3 8 GAME 14 4 4 3 3 8 GAME 15 3 0 3 5 8 GAME 16 3 2 2 3 5 8 GAME 17 3 1 2 3 3 8 GAME 18 2 3 0 3...
output:
RQKNBBRN RKNQNBBR NRNKBBQR RKNRBQNB RKQBBNNR RQKNBBRN RKNQNBBR RKQNNRBB RKNBBNQR RKNBBQNR RQKNBBRN RKNQNBBR RKQNNRBB RKNBBNQR RQKNBBRN RNBQKRNB NNRBBKQR RKNBQNBR RKNBNQBR RKQBNNBR RQKNBBRN RNBQKRNB NNRBBKQR RKNBQNBR RQKNBBRN RNBQKRNB NNRBBKQR RKNBQNBR RKNBNQBR RQKNBBRN RNKBBNRQ QRKRBBNN RKQNBBNR RQK...
result:
ok (c) correct after 96 tests, max moves 6 (96 test cases)
Test #4:
score: 0
Accepted
time: 76ms
memory: 3724kb
input:
GAME 1 4 2 8 GAME 2 4 2 6 8 GAME 3 3 3 6 8 GAME 4 2 0 1 4 8 GAME 5 2 0 2 4 8 GAME 6 2 0 2 3 8 GAME 7 3 3 3 2 6 8 GAME 8 3 5 3 8 GAME 9 2 3 3 8 GAME 10 1 1 0 3 2 8 GAME 11 1 1 1 3 8 GAME 12 1 1 1 2 8 GAME 13 2 0 1 1 8 GAME 14 2 0 1 2 8 GAME 15 1 1 1 8 GAME 16 3 3 5 5 8 GAME 17 4 1 4 8 GAME 18 3 2 4 2...
output:
RQKNBBRN RNKBBNRQ QRKRBBNN RQKNBBRN RNKBBNRQ QRKRBBNN NRKRBBQN RQKNBBRN NRBKQBRN NRKQBBNR NRKRBBNQ RQKNBBRN RKNQNBBR NNRBBKRQ QRBNKNRB QRKRBNNB RQKNBBRN RKNQNBBR NNRBBKRQ NRBNKQRB NRKRBQNB RQKNBBRN RKNQNBBR NNRBBKRQ NRBNKQRB NRKRBNQB RQKNBBRN NRBKQBRN NRKQBBNR RQBKNBNR BRKRNBQN QRKRNBBN RQKNBBRN NRB...
result:
ok (c) correct after 96 tests, max moves 6 (96 test cases)
Test #5:
score: 0
Accepted
time: 72ms
memory: 3752kb
input:
GAME 1 4 1 5 8 GAME 2 3 3 1 4 8 GAME 3 2 4 2 2 8 GAME 4 2 3 2 3 5 8 GAME 5 1 3 2 8 GAME 6 1 3 2 6 8 GAME 7 2 1 0 3 8 GAME 8 2 2 2 2 4 8 GAME 9 1 4 1 3 8 GAME 10 3 2 0 3 8 GAME 11 3 2 0 4 8 GAME 12 2 2 2 2 8 GAME 13 2 3 1 2 1 8 GAME 14 2 3 2 2 8 GAME 15 1 2 1 3 2 8 GAME 16 2 2 4 1 4 8 GAME 17 1 6 5 8...
output:
RQKNBBRN RNKBBNRQ RKQNRBBN RQNKRBBN RQKNBBRN NRBKQBRN NRKQBBNR RKNRQBBN RNQKRBBN RQKNBBRN RKNQNBBR RKQNNRBB RKNBBNQR RNNKRBBQ RQKNBBRN RKNQNBBR NRNKBBQR RKNRBQNB RBNKRQBN RQNKRNBB RQKNBBRN RNBQKRNB RNBBNKQR RNQKRNBB RQKNBBRN RNBQKRNB RNBBNKQR RNQKRNBB RNNKRQBB RQKNBBRN RKNQNBBR BRKBNNRQ RNBNKRQB RBB...
result:
ok (c) correct after 96 tests, max moves 6 (96 test cases)
Test #6:
score: 0
Accepted
time: 83ms
memory: 3728kb
input:
GAME 1 3 6 5 8 GAME 2 3 8 GAME 3 2 2 1 8 GAME 4 1 2 1 2 4 8 GAME 5 1 2 2 8 GAME 6 1 2 1 1 1 8 GAME 7 4 2 5 3 8 GAME 8 4 2 4 3 8 GAME 9 3 5 8 GAME 10 2 1 3 4 2 8 GAME 11 2 0 3 3 8 GAME 12 2 1 2 3 8 GAME 13 1 1 1 3 1 8 GAME 14 1 1 1 3 2 8 GAME 15 1 0 2 3 2 8 GAME 16 1 2 4 3 8 GAME 17 1 2 5 2 8 GAME 18...
output:
RQKNBBRN NRBKQBRN NRBQKBRN QRBKNBRN RQKNBBRN NRBKQBRN RQKNBBRN RKNQNBBR RQBBKNNR NRBKNBRQ RQKNBBRN RNBQKRNB BNRKQBNR RKNRQNBB BRNQNKRB QRBKNNRB RQKNBBRN RNBQKRNB BNRKQBNR NRBKQNRB RQKNBBRN RNBQKRNB BNRKQBNR RKNRQNBB NBRNKRBQ NRBKNQRB RQKNBBRN RNKBBNRQ QRKRBBNN RKQRBBNN QRNKBBRN RQKNBBRN RNKBBNRQ QRK...
result:
ok (c) correct after 96 tests, max moves 6 (96 test cases)
Test #7:
score: 0
Accepted
time: 75ms
memory: 3640kb
input:
GAME 1 2 2 4 1 8 GAME 2 3 2 1 8 GAME 3 2 1 1 4 3 8 GAME 4 3 1 3 3 3 8 GAME 5 2 4 3 2 1 8 GAME 6 2 3 1 1 8 GAME 7 3 2 0 1 8 GAME 8 2 1 1 8 GAME 9 1 6 4 4 8 GAME 10 3 1 2 2 1 8 GAME 11 1 8 GAME 12 2 1 0 8 GAME 13 3 1 5 3 8 GAME 14 2 2 3 4 2 8 GAME 15 1 4 2 5 8 GAME 16 3 0 3 2 8 GAME 17 2 2 2 8 GAME 18...
output:
RQKNBBRN RKNQNBBR RQBBKNNR RNQBBNKR RBBQKRNN RQKNBBRN NRBKQBRN QRKNNBBR RBBNKRQN RQKNBBRN RKNQNBBR BRKBNNRQ RNBBKRQN RBBKRNQN RBBNKRNQ RQKNBBRN NRBKQBRN RKNBBRQN RNKBRQBN RKNNRBBQ RBQNKRBN RQKNBBRN RKNQNBBR RKQNNRBB RNKBNQBR RKBRNBNQ RBNQKRBN RQKNBBRN RKNQNBBR NRNKBBQR RQBBNNKR RBNNKRBQ RQKNBBRN NRB...
result:
ok (c) correct after 96 tests, max moves 6 (96 test cases)
Test #8:
score: 0
Accepted
time: 80ms
memory: 3724kb
input:
GAME 1 0 2 4 5 8 GAME 2 0 3 4 3 8 GAME 3 0 1 1 2 8 GAME 4 2 4 2 2 3 8 GAME 5 2 3 4 8 GAME 6 1 2 2 2 8 GAME 7 1 4 1 2 8 GAME 8 2 0 1 2 3 8 GAME 9 1 3 0 3 4 8 GAME 10 2 0 2 1 3 8 GAME 11 1 3 3 0 8 GAME 12 0 1 6 5 8 GAME 13 2 0 1 3 2 8 GAME 14 0 1 8 GAME 15 1 4 3 5 8 GAME 16 2 1 0 3 3 8 GAME 17 1 3 0 3...
output:
RQKNBBRN BBQRNNKR QRBBNKNR NRBBKNQR QRNBKNBR RQKNBBRN BBQRNNKR NRBBNQKR NBRKNQBR NRQBKNBR RQKNBBRN BBQRNNKR BNRQKRNB NRBKRNQB NRNBKQBR RQKNBBRN RKNQNBBR RKQNNRBB RKNBBNQR RNNKRBBQ QRNNKBBR RQKNBBRN RKNQNBBR NRNKBBQR NRQNKBBR RQKNBBRN RNBQKRNB BNRKQBNR NRBKQNRB NRNQKBBR RQKNBBRN RNBQKRNB QNBRKNRB RKN...
result:
ok (c) correct after 96 tests, max moves 6 (96 test cases)
Test #9:
score: 0
Accepted
time: 65ms
memory: 3760kb
input:
GAME 1 0 4 6 4 8 GAME 2 0 3 4 4 8 GAME 3 0 4 8 GAME 4 0 4 5 3 8 GAME 5 0 5 5 3 8 GAME 6 0 3 3 8 GAME 7 1 4 5 2 8 GAME 8 2 2 5 3 8 GAME 9 1 3 4 3 2 8 GAME 10 1 2 3 3 2 8 GAME 11 2 4 1 3 2 8 GAME 12 1 2 3 2 8 GAME 13 3 3 1 2 6 8 GAME 14 4 2 1 8 GAME 15 3 2 2 1 8 GAME 16 5 4 4 8 GAME 17 4 3 1 6 8 GAME ...
output:
RQKNBBRN BBQRNNKR NBBRKNQR NBBRNKQR QBBRKNNR RQKNBBRN BBQRNNKR NRBBNQKR NBRKNQBR NBBRKQNR RQKNBBRN BBQRNNKR NBBRKNQR RQKNBBRN BBQRNNKR NBBRKNQR NBBQRNKR QBNRKNBR RQKNBBRN BBQRNNKR BBNRKNQR BBRKNNQR NBQRKNBR RQKNBBRN BBQRNNKR NRBBNQKR NBNRKQBR RQKNBBRN RNBQKRNB QNBRKNRB NRBQKNRB QNBRKBNR RQKNBBRN RKN...
result:
ok (c) correct after 96 tests, max moves 6 (96 test cases)
Test #10:
score: -100
Wrong Answer
time: 36ms
memory: 3696kb
input:
GAME 1 0 4 2 6 8 GAME 2 1 1 3 1 8 GAME 3 1 0 5 5 8 GAME 4 1 1 4 2 4 8 GAME 5 0 2 4 2 8 GAME 6 0 3 3 1 8 GAME 7 2 1 0 1 5 8 GAME 8 1 2 3 1 8 GAME 9 2 1 0 2 8 GAME 10 1 0 4 3 4 8 GAME 11 0 3 3 4 8 GAME 12 1 0 5 8 GAME 13 1 2 4 2 8 GAME 14 2 1 1 1 4 8 GAME 15 1 1 8 GAME 16 0 2 5 3 8 GAME 17 1 0 2 3 8 G...
output:
RQKNBBRN BBQRNNKR NBBRKNQR BBRKNQNR BBRQNKNR RQKNBBRN RNBQKRNB NNRBBKQR NRBKNBQR BBRNQKNR RQKNBBRN RNBQKRNB BBRNQNKR NBRNQKBR BBRNNKQR RQKNBBRN RNBQKRNB NNRBBKQR NBRQBNKR BNRKNBQR BQRBNKNR RQKNBBRN BBQRNNKR QRBBNKNR NRBBKNQR BNRBQKNR RQKNBBRN BBQRNNKR NRBBNQKR NBNRKQBR BNRBNKQR RQKNBBRN RKNQNBBR BRK...
result:
wrong answer (i) illegal position "" (game 43, guess 1) (test case 43)