QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#176151 | #7179. Fischer's Chess Guessing Game | ucup-team027 | AC ✓ | 1281ms | 3972kb | C++23 | 1.7kb | 2023-09-11 11:24:46 | 2023-09-11 11:24:46 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
vector<string> conf;
void init() {
string s = "RQKBBNRN";
sort(s.begin(), s.end());
do {
vector<int> kpos, rpos, bpos;
for (int i = 0; i < 8; i++) {
if (s[i] == 'K') kpos.push_back(i);
else if (s[i] == 'R') rpos.push_back(i);
else if (s[i] == 'B') bpos.push_back(i);
}
bool ok = 1;
if (kpos[0] < rpos[0] || kpos[0] > rpos[1]) ok = 0;
if (bpos[0] % 2 == bpos[1] % 2) ok = 0;
if (ok) conf.push_back(s);
} while (next_permutation(s.begin(), s.end()));
assert(conf.size() == 960);
}
int dist(string s1, string s2) {
int ans = 0;
for (int i = 0; i < 8; i++) {
if (s1[i] == s2[i]) ans++;
}
return ans;
}
void solve() {
random_shuffle(conf.begin(), conf.end());
vector<int> avail(960, 1);
for (int _ = 0; _ < 5; _++) {
if (accumulate(avail.begin(), avail.end(), 0) == 1) {
break;
}
int cz = 0, cost = 999999;
for (int i = 0; i < 960; i++) {
vector<int> hist(9);
for (int j = 0; j < 960; j++) {
if (!avail[j]) continue;
hist[dist(conf[i], conf[j])]++;
}
int cs = *max_element(hist.begin(), hist.end());
if (cs < cost) {
cost = cs;
cz = i;
}
}
cout << conf[cz] << endl;
int x; cin >> x;
if (x == 8) return;
for (int i = 0; i < 960; i++) {
if (!avail[i]) continue;
if (dist(conf[i], conf[cz]) != x) avail[i] = 0;
}
}
for (int i = 0; i < 960; i++) {
if (avail[i] == 1) {
cout << conf[i] << endl;
int x; cin >> x;
return;
}
}
assert(0);
}
signed main() {
//ios::sync_with_stdio(0); cin.tie(0);
srand(time(NULL));
init();
string s; int ts;
while (cin >> s) {
if (s == "END") break;
cin >> ts;
solve();
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 11ms
memory: 3736kb
input:
GAME 1 3 1 4 0 1 8 END
output:
RQKNBBRN NRNKBBQR RKBRNQNB BRNKNBRQ QRNBKNBR RKRBBQNN
result:
ok (c) correct after 1 tests, max moves 6 (1 test case)
Test #2:
score: 0
Accepted
time: 1255ms
memory: 3744kb
input:
GAME 1 3 1 4 0 1 8 GAME 2 3 0 3 0 2 8 GAME 3 2 3 4 2 2 8 GAME 4 2 0 2 3 8 GAME 5 2 3 4 2 8 GAME 6 1 3 5 2 8 GAME 7 4 2 3 0 8 GAME 8 1 3 2 3 3 8 GAME 9 1 4 0 2 2 8 GAME 10 0 3 3 3 8 GAME 11 3 0 5 1 8 GAME 12 1 2 5 0 3 8 GAME 13 3 4 3 4 8 GAME 14 0 3 3 3 0 8 GAME 15 3 3 4 0 8 GAME 16 1 4 3 3 8 GAME 17...
output:
RQKNBBRN NRNKBBQR RKBRNQNB BRNKNBRQ QRNBKNBR RKRBBQNN RQKNBBRN NRKQNBBR BNRBQKRN QNBNRKRB RBNKQNBR RKRBBNQN NRNBBKQR RNQBBKRN RQBBKNNR RBQKRNBN NRKBQNBR RKRBBNNQ RQKNBBRN NRKQBBNR BNRNQKRB RKBNQRNB RKRBQNBN NRBBNKQR RNBBQKRN RQKBNNBR QNRBBKNR RKRBNQBN RQKNBBRN RQBKNNRB RKNBNQBR NNRBBKQR RKRBNNBQ RQK...
result:
ok (c) correct after 96 tests, max moves 6 (96 test cases)
Test #3:
score: 0
Accepted
time: 1211ms
memory: 3728kb
input:
GAME 1 4 3 2 1 8 GAME 2 2 3 4 4 8 GAME 3 5 4 3 8 GAME 4 2 3 5 1 8 GAME 5 2 3 5 3 8 GAME 6 3 3 3 0 3 8 GAME 7 2 3 2 3 3 8 GAME 8 2 3 3 3 3 8 GAME 9 4 2 3 6 8 GAME 10 2 1 0 3 1 8 GAME 11 1 1 3 5 8 GAME 12 3 3 2 1 3 8 GAME 13 4 2 1 2 8 GAME 14 5 5 4 8 GAME 15 0 1 1 5 8 GAME 16 3 2 0 4 8 GAME 17 0 3 0 3...
output:
RQKBBNRN RQKNBRNB NRQNBKRB BRKQNRNB RKQBBNNR RQKNBBRN NRKQBBNR RBNNBKQR RNKBBRNQ RKNBBQNR NRNBBKQR BQNBRNKR RKNNRBBQ RKNBBNQR NRNBBKQR RNQBBKRN RQNBKNBR RNBQKBRN RKQBNNBR NRBBNKQR RNBBQKRN RQKBNNBR RKBBNRQN RKNBQNBR NRNBBKQR RNKBBQRN QRBBNNKR BRQNKNRB RNBBQNKR RKNBNQBR NRNBBKQR RNQBBKRN RQNBKNBR RQK...
result:
ok (c) correct after 96 tests, max moves 6 (96 test cases)
Test #4:
score: 0
Accepted
time: 1248ms
memory: 3736kb
input:
GAME 1 2 2 1 0 5 8 GAME 2 3 4 0 2 8 GAME 3 3 2 1 8 GAME 4 3 2 3 5 8 GAME 5 2 5 4 2 8 GAME 6 3 3 1 1 8 GAME 7 3 2 2 0 8 GAME 8 2 3 0 3 0 8 GAME 9 1 2 1 4 8 GAME 10 2 0 4 5 8 GAME 11 2 3 0 1 0 8 GAME 12 3 0 0 5 8 GAME 13 2 2 3 4 1 8 GAME 14 3 3 2 8 GAME 15 3 2 0 4 4 8 GAME 16 1 1 2 2 4 8 GAME 17 2 1 1...
output:
NRNBBKQR RNQBBKRN RNBBKQNR BBRNNKRQ RNKRBBNQ QRKRBBNN RQKBBNRN NRNBBKQR RNNBKQBR NNBRKQRB NRKRBBQN NRNBBKQR RQKBBNRN RBNQBKRN NRKRBBNQ RQKBBNRN NRNBBKQR NRKBQNBR RBKRBNNQ QRKRBNNB RQKNBBRN NRKQBBNR BRKQRNNB RKBRNNQB NRKRBQNB RQKBBNRN NRQBBKNR RNQBKNBR NQBBRKRN NRKRBNQB RQKNBBRN NRNKBBQR QBRKBNRN RNN...
result:
ok (c) correct after 96 tests, max moves 6 (96 test cases)
Test #5:
score: 0
Accepted
time: 1281ms
memory: 3972kb
input:
GAME 1 0 4 2 5 8 GAME 2 0 4 4 5 8 GAME 3 1 3 2 3 3 8 GAME 4 1 0 2 2 5 8 GAME 5 0 6 3 2 8 GAME 6 1 3 4 4 2 8 GAME 7 2 1 3 3 1 8 GAME 8 2 0 1 4 0 8 GAME 9 1 0 3 2 4 8 GAME 10 1 3 1 4 1 8 GAME 11 3 0 1 3 1 8 GAME 12 2 2 2 3 2 8 GAME 13 0 2 3 1 8 GAME 14 2 0 0 2 8 GAME 15 1 0 5 3 1 8 GAME 16 0 5 3 2 8 G...
output:
NRBBNKQR RKNNRQBB RNNQBKRB RNKQRBBN RQNKRBBN NRNBBKQR RNKQRNBB RBKNRQBN RNBKRBNQ RNQKRBBN RQKBBNRN RNBBNKRQ RBBNKRNQ RNKRNQBB RKNQNRBB RNNKRBBQ NRNBBKQR QRKNBBNR QBRKNRBN BBRKQNRN NRQKRNBB RQNKRNBB NRNBBKQR RNKQRNBB RQBKNRNB NRBKQRNB RNQKRNBB RQKNBBRN RQBKNNRB RKNBNQBR NRQKRNBB RKQNNBBR RNNKRQBB RQK...
result:
ok (c) correct after 96 tests, max moves 6 (96 test cases)
Test #6:
score: 0
Accepted
time: 1277ms
memory: 3680kb
input:
GAME 1 2 1 4 5 0 8 GAME 2 3 4 1 3 8 GAME 3 2 3 0 3 1 8 GAME 4 3 3 2 1 1 8 GAME 5 3 3 3 2 0 8 GAME 6 1 2 5 1 8 GAME 7 3 3 3 0 3 8 GAME 8 2 2 1 1 0 8 GAME 9 2 1 3 1 1 8 GAME 10 3 2 1 6 8 GAME 11 3 2 1 1 0 8 GAME 12 2 4 0 0 8 GAME 13 1 2 2 1 6 8 GAME 14 2 1 3 5 2 8 GAME 15 1 2 3 4 2 8 GAME 16 0 2 1 5 3...
output:
RQKBBNRN NRKBBQNR NRBKQNRB QBBRNKRN RQNBBNKR QRBKNBRN RQKNBBRN NRNKBBQR RKNBQNBR RKBBNQRN NRBKQBRN RQKNBBRN NRKQBBNR RBNNBKQR RKBNRBNQ RNNBKRBQ NRBKNBRQ NRBBNKQR RQBBKNRN BRKBQNNR BRQBKRNN NNBQRBKR QRBKNNRB NRBBNKQR RQBBKNRN BRKBQNNR RNKBQNBR RBKNNRBQ NRBKQNRB RQKBBNRN NRQBBNKR NRQKNRBB RNNQKRBB NRB...
result:
ok (c) correct after 96 tests, max moves 6 (96 test cases)
Test #7:
score: 0
Accepted
time: 1274ms
memory: 3972kb
input:
GAME 1 1 1 2 4 2 8 GAME 2 2 0 0 3 0 8 GAME 3 2 1 5 3 8 GAME 4 3 0 2 2 8 GAME 5 2 1 4 3 1 8 GAME 6 1 0 1 0 8 GAME 7 3 0 2 0 8 GAME 8 3 1 2 3 2 8 GAME 9 1 2 4 0 8 GAME 10 2 1 2 3 2 8 GAME 11 1 0 4 1 3 8 GAME 12 1 1 4 5 2 8 GAME 13 2 3 3 6 8 GAME 14 1 3 6 2 8 GAME 15 2 1 0 4 8 GAME 16 1 2 4 6 8 GAME 17...
output:
NRBBNKQR BRNNKBQR RKQNRBBN RBBKRNNQ BQRKNRNB RBBQKRNN RQKBBNRN NRKBBQNR BNQRNKRB NBRKQRBN BQRKNNRB RBBNKRQN RQKNBBRN NRKQBBNR RBBQKNNR RBKNNQBR RBBNKRNQ RQKNBBRN NRNKBBQR RNKRNQBB BBRQNKRN RBQNKRBN RQKNBBRN NRKQBBNR RBBQKNNR RQNBNKBR RKQNBBNR RBNQKRBN RQKBBNRN NRQBBNKR RKBQRNNB BNRKNQRB RBNNKRBQ RQK...
result:
ok (c) correct after 96 tests, max moves 6 (96 test cases)
Test #8:
score: 0
Accepted
time: 1277ms
memory: 3740kb
input:
GAME 1 3 0 3 3 8 GAME 2 0 3 3 2 8 GAME 3 1 4 3 1 8 GAME 4 3 0 1 2 8 GAME 5 2 4 4 1 8 GAME 6 3 1 3 4 2 8 GAME 7 0 1 1 4 8 GAME 8 2 0 3 3 0 8 GAME 9 0 2 4 5 8 GAME 10 3 2 0 0 5 8 GAME 11 1 0 8 GAME 12 1 1 4 2 1 8 GAME 13 0 1 0 8 GAME 14 0 1 3 2 8 GAME 15 0 1 0 0 8 GAME 16 0 5 2 1 8 GAME 17 1 1 1 0 4 8...
output:
NRBBNKQR RBBNQKRN BNRBQNKR BRKBNQNR QRNBKNBR RQKNBBRN BBQRNNKR NBRQNKBR BRKBNRNQ NRQBKNBR RQKBBNRN NRQBBNKR BRQBNKNR RBQNBKNR NRNBKQBR NRNBBKQR RNKBBQRN NRBKQRNB NBQRKRBN QRNNKBBR RQKNBBRN NRKQBBNR RQBNKBNR RKBNQNRB NRQNKBBR NRBBNKQR RQBBKNRN NRNKBRQB NRQNBBKR QRBNKRNB NRNQKBBR NRNBBKQR RNKQRNBB RNB...
result:
ok (c) correct after 96 tests, max moves 6 (96 test cases)
Test #9:
score: 0
Accepted
time: 1240ms
memory: 3712kb
input:
GAME 1 1 2 3 1 0 8 GAME 2 0 1 5 3 8 GAME 3 1 1 4 4 1 8 GAME 4 2 0 0 1 2 8 GAME 5 2 1 1 3 3 8 GAME 6 2 0 0 4 3 8 GAME 7 2 2 5 1 8 GAME 8 1 2 1 1 4 8 GAME 9 3 0 2 0 8 GAME 10 1 2 1 4 4 8 GAME 11 2 0 0 5 1 8 GAME 12 2 1 1 6 8 GAME 13 1 0 3 0 4 8 GAME 14 4 3 0 4 8 GAME 15 2 0 2 3 4 8 GAME 16 4 1 4 2 8 G...
output:
RQKBBNRN NRQBBNKR BNRBKNQR BBRKNRQN RKNBQRBN QBBRKNNR RQKBBNRN NRQKNRBB QBBRNKNR BNNRKBQR NBBRKQNR RQKBBNRN RNBBNKRQ NBNRBQKR NBRNKQBR RNQKRNBB NBBRKNQR NRNBBKQR RNQBBKRN BRKNRQNB NNRKQRBB RBBNKRNQ QBNRKNBR NRNBBKQR RNQBBKRN BRNQKBRN RBBNKQNR NRNBKRBQ NBQRKNBR NRBBNKQR RNBBQKRN BRKQNRNB NBQRBNKR RNN...
result:
ok (c) correct after 96 tests, max moves 6 (96 test cases)
Test #10:
score: 0
Accepted
time: 1259ms
memory: 3740kb
input:
GAME 1 0 4 2 5 8 GAME 2 1 2 5 2 1 8 GAME 3 1 2 5 1 8 GAME 4 4 1 1 4 8 GAME 5 0 2 4 3 8 GAME 6 5 5 2 8 GAME 7 2 3 5 3 8 GAME 8 4 3 0 2 8 GAME 9 2 3 6 8 GAME 10 2 1 3 4 3 8 GAME 11 0 3 3 6 8 GAME 12 1 0 3 0 1 8 GAME 13 3 1 2 2 2 8 GAME 14 3 5 3 8 GAME 15 1 0 6 1 8 GAME 16 0 2 4 3 2 8 GAME 17 1 2 3 3 1...
output:
RQKNBBRN BBQRNNKR NRBBNQKR BBRQKRNN BBRQNKNR RQKNBBRN NRQNBBKR BQRBNKNR QNBRKBNR QNRKRNBB BBRNQKNR RQKNBBRN NRQNBBKR BQRBNKNR BRKBQRNN BBRNNKQR NRBBNKQR RNBBKNRQ BRNKQBRN BQNBRNKR BQRBNKNR RQKNBBRN BBQRNNKR RNBBNKQR NNBBRQKR BNRBQKNR NRBBNKQR BQRBNNKR NRBBQNKR BNRBNKQR RQKNBBRN NRKQBBNR RBNNBKQR QNR...
result:
ok (c) correct after 96 tests, max moves 6 (96 test cases)
Test #11:
score: 0
Accepted
time: 1262ms
memory: 3676kb
input:
GAME 1 3 3 3 0 3 8 GAME 2 2 3 4 4 8 GAME 3 2 2 5 3 8 GAME 4 1 4 4 3 8 GAME 5 2 2 6 3 8 GAME 6 2 2 5 3 8 GAME 7 2 3 4 4 8 GAME 8 2 3 4 0 0 8 GAME 9 4 3 1 2 8 GAME 10 0 3 1 3 8 GAME 11 3 0 2 1 8 GAME 12 2 3 3 5 3 8 GAME 13 0 4 2 2 8 GAME 14 4 2 3 0 8 GAME 15 0 3 4 2 8 GAME 16 0 4 3 2 8 GAME 17 5 2 1 8...
output:
RQKNBBRN NRNKBBQR RNNQBKRB NRBKRBQN NQNRBKRB RQNBBNKR NRBBNKQR RNBBQKRN RQKBNNBR QNRBBKNR RNQBBNKR RQKNBBRN NRKQBBNR QNNRBBKR RNBKNQRB RNNBBQKR NRBBNKQR BRNNKBQR QNBNRBKR BRNBNQKR RQNNBBKR RQKBBNRN NRKBBQNR RNQKBBNR NQRNKBBR RNQNBBKR RQKBBNRN NRKBBQNR RNQKBBNR RNKBBRQN RNNQBBKR RQKBBNRN NRKBBQNR BBN...
result:
ok (c) correct after 96 tests, max moves 6 (96 test cases)
Extra Test:
score: 0
Extra Test Passed