QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#176685 | #7179. Fischer's Chess Guessing Game | ucup-team1359 | AC ✓ | 84ms | 7512kb | C++14 | 2.3kb | 2023-09-11 21:28:15 | 2023-09-11 21:28:16 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
string tmp,st[1000],bf;
int cnt=0,id;
int same(int x,int y) {
int res=0;
for (int i=0;i<8;i++) if (st[x][i]==st[y][i]) res++;
return res;
}
vector<int> vec[2];
int sres[1000][1000];
int calcmax() {
int calc[9]={0,0,0,0,0,0,0,0,0},res=0;
int minx=cnt,miny=0;
for (int j=0;j<vec[0].size();j++) {
int curx=vec[0][j];
memset(calc,0,sizeof(calc));
for (auto cury:vec[0]) calc[sres[curx][cury]]++;
res=0;
for (int i=0;i<9;i++) res=max(res,calc[i]);
if (res<=minx) {
minx=res;
miny=curx;
}
}
return miny;
}
int queri(int x) {
int y=0;
cout<<st[x]<<endl;
cin>>y;
return y;
}
void solve() {
vec[0].clear();vec[1].clear();
for (int i=1;i<=960;i++) vec[0].push_back(i);
int cur=0,tmpx=0;
while (1) {
cur++;
tmpx=calcmax();
int x=queri(tmpx);
if (x==8) return;
for (auto cur:vec[0]) {
if (sres[tmpx][cur]==x) vec[1].push_back(cur);
}
vec[0].clear();
for (auto cur:vec[1]) vec[0].push_back(cur);
vec[1].clear();
}
}
int main() {
for (int i=0;i<8;i++) {
for (int j=i+1;j<8;j++) {
for (int k=j+1;k<8;k++) {
for (int x=0;x<7;x+=2) {
if ((x==i)||(x==j)||(x==k)) continue;
for (int y=1;y<8;y+=2) {
if ((y==i)||(y==j)||(y==k)) continue;
for (int z=0;z<8;z++) {
if ((z==i)||(z==j)||(z==k)||(z==x)||(z==y)) continue;
tmp="NNNNNNNN";
tmp[i]=tmp[k]='R';
tmp[j]='K';
tmp[x]=tmp[y]='B';
tmp[z]='Q';
st[++cnt]=tmp;
}
}
}
}
}
}
mt19937 sf(11);
shuffle(st+1,st+1+cnt,sf);
for (int i=1;i<=cnt;i++) {
for (int j=1;j<=cnt;j++) sres[i][j]=same(i,j);
}
cin>>bf;
while (bf!="END") {
cin>>id;
solve();
cin>>bf;
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 3ms
memory: 7384kb
input:
GAME 1 3 1 5 4 8 END
output:
RQKNBBRN NRBKQBRN RKNBBRQN RKNBBNRQ RKRBBQNN
result:
ok (c) correct after 1 tests, max moves 5 (1 test case)
Test #2:
score: 0
Accepted
time: 66ms
memory: 7512kb
input:
GAME 1 3 1 5 4 8 GAME 2 3 1 6 8 GAME 3 2 2 4 4 2 8 GAME 4 2 3 0 2 8 GAME 5 2 4 4 3 8 GAME 6 1 1 1 1 8 GAME 7 4 3 2 8 GAME 8 5 3 3 8 GAME 9 4 4 5 2 8 GAME 10 2 3 1 2 1 8 GAME 11 3 0 1 5 8 GAME 12 3 0 2 3 3 8 GAME 13 3 2 0 3 8 GAME 14 4 3 2 5 8 GAME 15 3 1 2 2 8 GAME 16 1 3 2 0 6 8 GAME 17 2 3 0 3 8 G...
output:
RQKNBBRN NRBKQBRN RKNBBRQN RKNBBNRQ RKRBBQNN RQKNBBRN NRBKQBRN RKNBBRQN RKRBBNQN RQKNBBRN RKNQNBBR RQBBKNNR RNQBBNKR RBBNQNKR RKRBBNNQ RQKNBBRN RKNQNBBR NRNKBBQR RNKRNQBB RKRBQNBN RQKNBBRN RKNQNBBR RKQNNRBB RKBQNNRB RKRBNQBN RQKNBBRN RNBQKRNB BBRNQKNR BRNKNQRB RKRBNNBQ RQKNBBRN RQBNKBNR RBKNBNQR RKR...
result:
ok (c) correct after 96 tests, max moves 6 (96 test cases)
Test #3:
score: 0
Accepted
time: 65ms
memory: 7508kb
input:
GAME 1 2 3 2 1 1 8 GAME 2 2 4 2 6 8 GAME 3 2 4 2 8 GAME 4 1 1 1 1 6 8 GAME 5 1 1 2 1 1 8 GAME 6 1 1 1 3 2 8 GAME 7 4 5 2 8 GAME 8 3 1 4 8 GAME 9 4 4 4 2 8 GAME 10 3 1 2 2 6 8 GAME 11 2 8 GAME 12 3 2 2 2 4 8 GAME 13 4 2 3 8 GAME 14 4 1 4 3 8 GAME 15 3 0 3 2 4 8 GAME 16 3 2 0 8 GAME 17 3 1 2 5 8 GAME ...
output:
RQKNBBRN RKNQNBBR NRNKBBQR RBNKQRBN QNRNKBBR RKQBBNNR RQKNBBRN RKNQNBBR RKQNNRBB RKNBBNQR RKNBBQNR RQKNBBRN RKNQNBBR RKQNNRBB RKNBBNQR RQKNBBRN RNBQKRNB BBRNQKNR BRNKNQRB RKRBNNBQ RKQBNNBR RQKNBBRN RNBQKRNB BBRNQKNR BRNKRBNQ QBRKNRBN RKNBQNBR RQKNBBRN RNBQKRNB BBRNQKNR BRNKNQRB NRBBNKRQ RKNBNQBR RQK...
result:
ok (c) correct after 96 tests, max moves 6 (96 test cases)
Test #4:
score: 0
Accepted
time: 63ms
memory: 7512kb
input:
GAME 1 4 2 3 5 8 GAME 2 4 1 2 5 8 GAME 3 3 3 6 8 GAME 4 2 0 1 4 8 GAME 5 2 0 2 1 8 GAME 6 2 0 2 0 8 GAME 7 3 3 3 2 8 GAME 8 3 5 3 8 GAME 9 2 3 3 8 GAME 10 1 1 0 6 8 GAME 11 1 1 1 2 8 GAME 12 1 1 0 8 GAME 13 2 0 1 1 6 8 GAME 14 2 0 1 2 8 GAME 15 1 1 2 5 8 GAME 16 3 3 5 5 8 GAME 17 4 2 4 2 8 GAME 18 3...
output:
RQKNBBRN RQBNKBNR RNKQRBBN RBKRBQNN QRKRBBNN RQKNBBRN RQBNKBNR RNKBBNRQ NRQKBBRN NRKRBBQN RQKNBBRN NRBKQBRN NRKQBBNR NRKRBBNQ RQKNBBRN RKNQNBBR NNRBBKRQ QRBNKNRB QRKRBNNB RQKNBBRN RKNQNBBR NNRBBKRQ BQRBKRNN NRKRBQNB RQKNBBRN RKNQNBBR NNRBBKRQ BQRBKRNN NRKRBNQB RQKNBBRN NRBKQBRN NRKQBBNR RQBKNBNR QRK...
result:
ok (c) correct after 96 tests, max moves 6 (96 test cases)
Test #5:
score: 0
Accepted
time: 65ms
memory: 7488kb
input:
GAME 1 4 3 1 3 8 GAME 2 3 3 1 4 8 GAME 3 2 4 2 2 8 GAME 4 2 3 2 4 8 GAME 5 1 3 3 1 8 GAME 6 1 3 2 1 0 8 GAME 7 2 1 1 2 1 8 GAME 8 2 2 2 2 8 GAME 9 1 4 1 6 8 GAME 10 3 2 1 5 8 GAME 11 3 2 2 0 8 GAME 12 2 2 2 2 4 8 GAME 13 2 3 1 2 8 GAME 14 2 3 2 8 GAME 15 1 2 1 2 2 8 GAME 16 2 2 4 1 2 8 GAME 17 1 6 5...
output:
RQKNBBRN RQBNKBNR RBKNBNQR RQBBNKRN RQNKRBBN RQKNBBRN NRBKQBRN NRKQBBNR RKNRQBBN RNQKRBBN RQKNBBRN RKNQNBBR RKQNNRBB RKNBBNQR RNNKRBBQ RQKNBBRN RKNQNBBR NRNKBBQR RBNKQRBN RQNKRNBB RQKNBBRN RNBQKRNB RNBBQNKR NNBRKBQR RNQKRNBB RQKNBBRN RNBQKRNB RNBBQNKR BNQRKBNR NRBBKRQN RNNKRQBB RQKNBBRN RKNQNBBR BBR...
result:
ok (c) correct after 96 tests, max moves 6 (96 test cases)
Test #6:
score: 0
Accepted
time: 72ms
memory: 7388kb
input:
GAME 1 3 6 5 8 GAME 2 3 8 GAME 3 2 2 1 8 GAME 4 1 2 1 3 8 GAME 5 1 2 2 8 GAME 6 1 2 1 2 8 GAME 7 4 1 2 6 8 GAME 8 4 1 2 8 GAME 9 3 5 8 GAME 10 2 1 1 2 8 GAME 11 2 0 3 3 2 8 GAME 12 2 1 1 3 1 8 GAME 13 1 1 3 1 5 8 GAME 14 1 1 4 3 1 8 GAME 15 1 0 2 3 3 8 GAME 16 1 2 4 2 3 8 GAME 17 1 2 5 2 8 GAME 18 1...
output:
RQKNBBRN NRBKQBRN BRNKQBRN QRBKNBRN RQKNBBRN NRBKQBRN RQKNBBRN RKNQNBBR RQBBKNNR NRBKNBRQ RQKNBBRN RNBQKRNB BNRKQBNR RKBBNNQR QRBKNNRB RQKNBBRN RNBQKRNB BNRKQBNR NRBKQNRB RQKNBBRN RNBQKRNB BNRKQBNR RKBBNNQR NRBKNQRB RQKNBBRN RQBNKBNR RNKBBNRQ NRQKBBRN QRNKBBRN RQKNBBRN RQBNKBNR RNKBBNRQ NRQKBBRN RQK...
result:
ok (c) correct after 96 tests, max moves 6 (96 test cases)
Test #7:
score: 0
Accepted
time: 67ms
memory: 7476kb
input:
GAME 1 2 2 4 1 3 8 GAME 2 3 2 1 1 8 GAME 3 2 1 3 1 2 8 GAME 4 3 1 3 8 GAME 5 2 4 3 4 8 GAME 6 2 3 1 1 8 GAME 7 3 2 0 2 8 GAME 8 2 1 0 3 8 GAME 9 1 6 4 4 8 GAME 10 3 1 2 1 4 8 GAME 11 1 8 GAME 12 2 1 1 3 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 4 8 GAME 17 2 2 2 8 GAME ...
output:
RQKNBBRN RKNQNBBR RQBBKNNR RNQBBNKR QRBNKBNR RBBQKRNN RQKNBBRN NRBKQBRN QRNNBKRB RNQKBBNR RBBNKRQN RQKNBBRN RKNQNBBR BBRNNKRQ NRNBBKRQ BRKNNRQB RBBNKRNQ RQKNBBRN NRBKQBRN RKNBBRQN RBQNKRBN RQKNBBRN RKNQNBBR RKQNNRBB RBNNQKBR RBNQKRBN RQKNBBRN RKNQNBBR NRNKBBQR RQBBNNKR RBNNKRBQ RQKNBBRN NRBKQBRN QRN...
result:
ok (c) correct after 96 tests, max moves 6 (96 test cases)
Test #8:
score: 0
Accepted
time: 72ms
memory: 7380kb
input:
GAME 1 0 2 4 5 8 GAME 2 0 3 1 4 8 GAME 3 0 1 1 2 8 GAME 4 2 4 2 2 3 8 GAME 5 2 3 4 2 2 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 2 5 8 GAME 10 2 0 2 8 GAME 11 1 3 2 3 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 4 8 GAME 16 2 1 3 0 8 GAME 17 1 3 0 1 8...
output:
RQKNBBRN BBQRNNKR QRBBNKNR NRBBKNQR QRNBKNBR RQKNBBRN BBQRNNKR BBNRKRNQ NBRKQNBR NRQBKNBR RQKNBBRN BBQRNNKR BNRQKRNB NRBKRNQB NRNBKQBR RQKNBBRN RKNQNBBR RKQNNRBB RKNBBNQR RNNKRBBQ QRNNKBBR RQKNBBRN RKNQNBBR NRNKBBQR QNNRBBKR BRNKNBRQ NRQNKBBR RQKNBBRN RNBQKRNB BNRKQBNR NRBKQNRB NRNQKBBR RQKNBBRN RNB...
result:
ok (c) correct after 96 tests, max moves 6 (96 test cases)
Test #9:
score: 0
Accepted
time: 74ms
memory: 7448kb
input:
GAME 1 0 4 5 8 GAME 2 0 3 4 2 8 GAME 3 0 4 4 5 8 GAME 4 0 4 4 8 GAME 5 0 5 3 5 8 GAME 6 0 3 4 1 8 GAME 7 1 4 5 2 8 GAME 8 2 2 5 8 GAME 9 1 3 3 8 GAME 10 1 2 3 3 2 8 GAME 11 2 4 1 2 8 GAME 12 1 2 3 2 8 GAME 13 3 3 1 2 8 GAME 14 4 3 3 2 8 GAME 15 3 2 3 4 2 8 GAME 16 5 4 5 8 GAME 17 4 1 3 8 GAME 18 4 2...
output:
RQKNBBRN BBQRNNKR BBRQKNNR QBBRKNNR RQKNBBRN BBQRNNKR BBNRKRNQ BBRKRNNQ NBBRKQNR RQKNBBRN BBQRNNKR BBRQKNNR QBNRKNBR NBBRKNQR RQKNBBRN BBQRNNKR BBRQKNNR QBNRKNBR RQKNBBRN BBQRNNKR BBNRNKQR NBBRQNKR NBQRKNBR RQKNBBRN BBQRNNKR BBNRKRNQ BBRKRNNQ NBNRKQBR RQKNBBRN RNBQKRNB QNBRKNRB NRBQKNRB QNBRKBNR RQK...
result:
ok (c) correct after 96 tests, max moves 6 (96 test cases)
Test #10:
score: 0
Accepted
time: 72ms
memory: 7448kb
input:
GAME 1 0 4 6 8 GAME 2 1 1 8 GAME 3 1 0 5 4 8 GAME 4 1 1 5 2 8 GAME 5 0 2 4 2 8 GAME 6 0 3 1 2 8 GAME 7 2 1 4 8 GAME 8 1 2 3 1 8 GAME 9 2 1 4 6 8 GAME 10 1 0 4 1 8 GAME 11 0 3 1 5 8 GAME 12 1 0 5 2 8 GAME 13 1 2 4 2 8 GAME 14 2 1 2 1 3 8 GAME 15 1 1 3 4 8 GAME 16 0 2 5 8 GAME 17 1 0 2 3 4 8 GAME 18 0...
output:
RQKNBBRN BBQRNNKR BBRQKNNR BBRQNKNR RQKNBBRN RNBQKRNB BBRNQKNR RQKNBBRN RNBQKRNB BBRNQNKR BQRBNNKR BBRNNKQR RQKNBBRN RNBQKRNB BBRNQKNR BBNNQRKR BQRBNKNR RQKNBBRN BBQRNNKR QRBBNKNR NRBBKNQR BNRBQKNR RQKNBBRN BBQRNNKR BBNRKRNQ NBRKQNBR BNRBNKQR RQKNBBRN RKNQNBBR BBRNNKRQ QBRNBKNR RQKNBBRN RNBQKRNB BNR...
result:
ok (c) correct after 96 tests, max moves 6 (96 test cases)
Test #11:
score: 0
Accepted
time: 84ms
memory: 7508kb
input:
GAME 1 3 0 5 8 GAME 2 2 2 4 8 GAME 3 2 3 3 0 8 GAME 4 5 3 2 3 8 GAME 5 4 4 3 5 8 GAME 6 3 1 3 1 5 8 GAME 7 0 6 4 8 GAME 8 0 4 3 8 GAME 9 0 4 2 8 GAME 10 2 3 3 3 8 GAME 11 1 1 2 4 2 8 GAME 12 2 3 4 4 2 8 GAME 13 0 4 2 5 8 GAME 14 0 3 0 8 GAME 15 0 3 0 6 8 GAME 16 2 3 3 3 6 8 GAME 17 1 2 2 3 8 GAME 18...
output:
RQKNBBRN NRBKQBRN RQKBNNBR RQNBBNKR RQKNBBRN RKNQNBBR RQBBKNNR RNQBBNKR RQKNBBRN RKNQNBBR NRNKBBQR NRKRNBBQ RNNBBQKR RQKNBBRN RNKNBQRB BRKNQBRN RQKBBRNN RQNNBBKR RQKNBBRN RQBNKBNR RKBNNBRQ RNKNQBBR RNQNBBKR RQKNBBRN NRBKQBRN RKNBBRQN RBQNKRBN RNNQBKRB RNNQBBKR RQKNBBRN BBQRNNKR BBNRNQKR BRQBNNKR RQK...
result:
ok (c) correct after 96 tests, max moves 6 (96 test cases)
Extra Test:
score: 0
Extra Test Passed