QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#269370 | #7179. Fischer's Chess Guessing Game | ideograph_advantage# | AC ✓ | 729ms | 3944kb | C++20 | 2.3kb | 2023-11-29 16:00:27 | 2023-11-29 16:00:28 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define iter(v) v.begin(), v.end()
#define SZ(v) int(v.size())
#define pb emplace_back
#define ff first
#define ss second
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#ifdef zisk
void debug(){cout << endl;}
template<class T, class ... U>
void debug(T a, U ... b){ cout << a << " ", debug(b...); }
template<class T> void pary(T l, T r){
while(l != r) cout << *l << " ", l++;
cout << endl;
}
#else
#define debug(...) void()
#define pary(...) void()
#endif
template<class A, class B>
ostream& operator<<(ostream& o, pair<A, B> p){
return o << '(' << p.ff << ',' << p.ss << ')';
}
bool testing = 0;
int queries = 0;
string qs;
int match(string &s, string &t) {
int ret = 0;
for (int i = 0;i < 8;i++)ret += s[i] == t[i];
return ret;
}
int query(string &s) {
int ret;
if (testing) {
queries++;
ret = match(s, qs);
} else {
cout << s << endl;
cin >> ret;
}
return ret;
}
vector<string> allstr;
void solve(vector<string> can) {
if (can.size() == 1) {
query(can[0]);
return;
}
string best;
int bval = 1000;
for (auto s:allstr) {
vector<int> cnt(9);
for (auto t:can) {
cnt[match(s, t)]++;
}
int ma = *max_element(cnt.begin(), cnt.end());
if (ma < bval) {
bval = ma;
best = s;
}
}
int que = query(best);
if (que == 8) return;
vector<string> rec;
for (auto s:can) {
if (match(s, best) == que) rec.push_back(s);
}
solve(rec);
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
vector<string> can;
string s = "BBKNNQRR";
do {
int bodd = 0, beven = 0;
int kp = 0, rp1 = -1, rp2 = -1;
for (int i = 0;i < 8;i++) {
if (s[i] == 'B') {
if (i %2) bodd++;
else beven++;
} else if (s[i] == 'K') {
kp = i;
} else if (s[i] == 'R') {
if (rp1 == -1) rp1 = i;
else rp2 = i;
}
}
if (bodd && beven && rp1 < kp && kp < rp2) can.push_back(s);
} while (next_permutation(s.begin(), s.end()));
allstr = can;
if (testing) {
for (string str:can) {
qs = str;
queries = 0;
solve(can);
if (queries > 6) {
debug("Bad", str);
}
}
return 0;
}
string game;
int gn;
while (cin >> game) {
if (game == "END") break;
cin >> gn;
solve(can);
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 9ms
memory: 3944kb
input:
GAME 1 1 0 2 4 8 END
output:
NRBBNKQR BRNNKBQR NBRKNQBR QBRKBRNN RKRBBQNN
result:
ok (c) correct after 1 tests, max moves 5 (1 test case)
Test #2:
score: 0
Accepted
time: 720ms
memory: 3768kb
input:
GAME 1 1 0 2 4 8 GAME 2 2 3 3 1 1 8 GAME 3 1 0 1 2 8 GAME 4 1 0 2 2 1 8 GAME 5 2 3 4 2 8 GAME 6 2 2 4 0 0 8 GAME 7 0 2 3 2 0 8 GAME 8 1 3 3 0 8 GAME 9 0 3 3 0 8 GAME 10 0 3 3 1 8 GAME 11 0 5 1 0 8 GAME 12 1 2 2 1 0 8 GAME 13 1 1 5 1 8 GAME 14 0 4 4 3 8 GAME 15 1 2 1 2 1 8 GAME 16 1 0 3 1 0 8 GAME 17...
output:
NRBBNKQR BRNNKBQR NBRKNQBR QBRKBRNN RKRBBQNN NRBBNKQR RNBBQKRN RQKBNNBR BBRNNQKR BBNNRKQR RKRBBNQN NRBBNKQR BRNNKBQR NBRKNQBR BNRKQRNB RKRBBNNQ NRBBNKQR BRNNKBQR NBRKNQBR QBRKBRNN BBNNQRKR RKRBQNBN NRBBNKQR RNBBQKRN RQKBNNBR QNRBBKNR RKRBNQBN NRBBNKQR RNBBQKRN QNRBKNBR BBNNQRKR BBNNRKQR RKRBNNBQ NRB...
result:
ok (c) correct after 96 tests, max moves 6 (96 test cases)
Test #3:
score: 0
Accepted
time: 725ms
memory: 3768kb
input:
GAME 1 2 2 3 1 2 8 GAME 2 2 2 2 5 2 8 GAME 3 3 1 4 2 8 GAME 4 3 1 3 1 1 8 GAME 5 2 3 5 2 8 GAME 6 3 1 3 0 2 8 GAME 7 1 3 5 1 8 GAME 8 1 3 3 4 8 GAME 9 2 1 3 2 3 8 GAME 10 2 1 0 0 4 8 GAME 11 2 1 1 3 2 8 GAME 12 1 4 3 4 8 GAME 13 0 2 2 3 8 GAME 14 1 1 2 2 2 8 GAME 15 0 1 0 1 8 GAME 16 0 2 2 1 8 GAME ...
output:
NRBBNKQR RNBBQKRN QNRBKNBR BNNQRBKR BBQNNRKR RKQBBNNR NRBBNKQR RNBBQKRN QNRBKNBR RBNNBQKR BBNNQRKR RKNBBQNR NRBBNKQR RBBNQKRN BQNBRNKR BRKRNNQB RKNBBNQR NRBBNKQR RBBNQKRN BQNBRNKR BBRNKNRQ BBNNRKQR RKQBNNBR NRBBNKQR RNBBQKRN RQKBNNBR BBNNRKQR RKNBQNBR NRBBNKQR RBBNQKRN BQNBRNKR BBRNKNRQ BBNQRKNR RKN...
result:
ok (c) correct after 96 tests, max moves 6 (96 test cases)
Test #4:
score: 0
Accepted
time: 726ms
memory: 3668kb
input:
GAME 1 1 2 1 4 0 8 GAME 2 3 1 0 1 8 GAME 3 2 0 3 0 8 GAME 4 1 1 0 1 0 8 GAME 5 2 0 4 0 0 8 GAME 6 3 0 1 0 8 GAME 7 2 1 1 0 8 GAME 8 2 2 1 1 0 8 GAME 9 3 0 0 6 8 GAME 10 2 0 4 1 0 8 GAME 11 2 1 3 1 1 8 GAME 12 3 0 0 4 8 GAME 13 2 2 1 1 2 8 GAME 14 3 1 4 5 8 GAME 15 2 1 1 3 1 8 GAME 16 1 3 0 4 8 GAME ...
output:
NRBBNKQR BRNNKBQR BNRBKRQN BRKQNBNR BBNNQRKR QRKRBBNN NRBBNKQR RBBNQKRN BQNBRNKR BNQRKRNB NRKRBBQN NRBBNKQR RNBBQKRN BRKQNRNB BBQNNRKR NRKRBBNQ NRBBNKQR BRNNKBQR RKQNRBBN BBRKNNRQ BBNNQRKR QRKRBNNB NRBBNKQR RNBBQKRN BRKQNRNB BBNQRNKR BBNNQRKR NRKRBQNB NRBBNKQR RBBNQKRN BNRBQNKR BBNQNRKR NRKRBNQB NRB...
result:
ok (c) correct after 96 tests, max moves 6 (96 test cases)
Test #5:
score: 0
Accepted
time: 729ms
memory: 3700kb
input:
GAME 1 0 4 5 2 8 GAME 2 0 3 0 2 8 GAME 3 0 4 5 3 8 GAME 4 0 5 1 3 8 GAME 5 0 4 4 2 8 GAME 6 0 6 4 1 8 GAME 7 1 0 2 5 8 GAME 8 3 4 1 3 8 GAME 9 2 2 0 0 2 8 GAME 10 0 1 0 2 8 GAME 11 1 2 3 1 3 8 GAME 12 0 2 4 0 8 GAME 13 1 0 4 2 1 8 GAME 14 0 3 1 1 8 GAME 15 1 1 2 1 3 8 GAME 16 2 2 0 1 1 8 GAME 17 1 0...
output:
NRBBNKQR RKNNRQBB QNRKRBBN BBNNRKRQ RQNKRBBN NRBBNKQR RKNNRQBB BQRNKRNB NRKQRNBB RNQKRBBN NRBBNKQR RKNNRQBB QNRKRBBN BBNNRKRQ RNNKRBBQ NRBBNKQR RKNNRQBB BBNRKQRN BBNQRNKR RQNKRNBB NRBBNKQR RKNNRQBB QNRKRBBN BBRKQNRN RNQKRNBB NRBBNKQR RKNNRQBB BNNRKQRB BBNNQRKR RNNKRQBB NRBBNKQR BRNNKBQR NBRKNQBR QBR...
result:
ok (c) correct after 96 tests, max moves 6 (96 test cases)
Test #6:
score: 0
Accepted
time: 723ms
memory: 3736kb
input:
GAME 1 3 3 1 2 0 8 GAME 2 3 4 0 0 8 GAME 3 4 3 1 0 8 GAME 4 3 2 0 3 8 GAME 5 3 3 0 2 1 8 GAME 6 4 2 0 1 8 GAME 7 1 3 1 1 1 8 GAME 8 2 2 0 4 0 8 GAME 9 2 1 5 1 8 GAME 10 1 2 0 2 1 8 GAME 11 2 1 5 0 8 GAME 12 2 1 6 2 8 GAME 13 3 0 2 3 2 8 GAME 14 2 1 3 5 4 8 GAME 15 4 2 4 4 8 GAME 16 4 1 4 5 8 GAME 17...
output:
NRBBNKQR RBBNQKRN BBQRNKNR BBNRQKRN BBNNRKQR QRBKNBRN NRBBNKQR RBBNQKRN BBNNRQKR BBNQRKNR NRBKQBRN NRBBNKQR BNRBNKRQ BNNRQBKR BNRBQKNR NRBKNBRQ NRBBNKQR RBBNQKRN BBNQRKNR BQRKNRNB QRBKNNRB NRBBNKQR RBBNQKRN BBQRNKNR BBRNKNRQ BBNNQRKR NRBKQNRB NRBBNKQR BNRBNKRQ BBNNRKQR BBNQRKRN NRBKNQRB NRBBNKQR BRN...
result:
ok (c) correct after 96 tests, max moves 6 (96 test cases)
Test #7:
score: 0
Accepted
time: 723ms
memory: 3744kb
input:
GAME 1 1 1 2 2 1 8 GAME 2 2 3 1 1 3 8 GAME 3 1 2 2 3 2 8 GAME 4 0 3 3 3 8 GAME 5 0 3 2 1 8 GAME 6 0 4 1 4 8 GAME 7 2 4 2 0 8 GAME 8 3 3 0 1 1 8 GAME 9 2 4 3 2 8 GAME 10 1 2 2 1 1 8 GAME 11 1 1 1 8 GAME 12 2 3 1 0 2 8 GAME 13 1 2 4 3 8 GAME 14 1 1 4 1 1 8 GAME 15 1 2 4 4 8 GAME 16 0 5 2 3 8 GAME 17 0...
output:
NRBBNKQR BRNNKBQR RKQNRBBN BBRNQKRN BBNNRKQR RBBQKRNN NRBBNKQR RNBBQKRN RQKBNNBR BBNRNKRQ BBNNQRKR RBBNKRQN NRBBNKQR BRNNKBQR BNRBKRQN BBNNRKRQ BBNQNRKR RBBNKRNQ NRBBNKQR RKNNRQBB BQRNKRNB NQNRKRBB RBQNKRBN NRBBNKQR RKNNRQBB BQRNKRNB QRNKBNRB RBNQKRBN NRBBNKQR RKNNRQBB QNRKRBBN BBNNQRKR RBNNKRBQ NRB...
result:
ok (c) correct after 96 tests, max moves 6 (96 test cases)
Test #8:
score: 0
Accepted
time: 718ms
memory: 3680kb
input:
GAME 1 3 0 3 3 8 GAME 2 4 1 2 2 8 GAME 3 4 1 2 4 8 GAME 4 2 0 1 2 3 8 GAME 5 3 1 1 2 2 8 GAME 6 3 0 1 3 3 8 GAME 7 0 0 6 3 8 GAME 8 1 4 1 5 8 GAME 9 0 1 4 4 8 GAME 10 1 2 6 2 8 GAME 11 2 3 1 1 2 8 GAME 12 1 2 6 1 8 GAME 13 0 2 0 3 8 GAME 14 0 1 5 2 8 GAME 15 1 4 2 3 8 GAME 16 0 2 0 2 8 GAME 17 1 1 2...
output:
NRBBNKQR RBBNQKRN BNRBQNKR BQNBNRKR QRNBKNBR NRBBNKQR BNRBNKRQ NQBRNBKR BBNRKQNR NRQBKNBR NRBBNKQR BNRBNKRQ NQBRNBKR BBNRKQNR NRNBKQBR NRBBNKQR RNBBQKRN BRKQNRNB BBRQKNNR BBNNQRKR QRNNKBBR NRBBNKQR RBBNQKRN BQNBRNKR BBRNNQKR BBNNQRKR NRQNKBBR NRBBNKQR RBBNQKRN BNRBQNKR BBNQNRKR BBNQRKNR NRNQKBBR NRB...
result:
ok (c) correct after 96 tests, max moves 6 (96 test cases)
Test #9:
score: 0
Accepted
time: 683ms
memory: 3632kb
input:
GAME 1 2 1 0 3 2 8 GAME 2 3 2 3 2 8 GAME 3 4 0 1 3 8 GAME 4 1 3 3 3 3 8 GAME 5 2 0 0 2 2 8 GAME 6 2 0 0 2 3 8 GAME 7 2 2 4 1 1 8 GAME 8 3 1 2 3 1 8 GAME 9 4 1 5 1 8 GAME 10 1 4 4 2 8 GAME 11 2 0 0 4 2 8 GAME 12 2 1 1 1 2 8 GAME 13 3 6 1 2 8 GAME 14 2 6 3 8 GAME 15 3 6 2 3 8 GAME 16 1 1 4 1 2 8 GAME ...
output:
NRBBNKQR RNBBQKRN NRNKBRQB BBRKRNNQ BBNNQRKR QBBRKNNR NRBBNKQR RBBNQKRN BBNQRKNR BBNRQKRN NBBRKQNR NRBBNKQR BNRBNKRQ BRNKQBNR BBNNRKQR NBBRKNQR NRBBNKQR BRNNKBQR RBQNBNKR BBNQRKNR BBNNQRKR QBNRKNBR NRBBNKQR RNBBQKRN BRKQNRNB BQRNKBNR BBNNQRKR NBQRKNBR NRBBNKQR RNBBQKRN BRKQNRNB BQRNKBNR BBNNQRKR NBN...
result:
ok (c) correct after 96 tests, max moves 6 (96 test cases)
Test #10:
score: 0
Accepted
time: 691ms
memory: 3764kb
input:
GAME 1 3 2 6 4 8 GAME 2 2 2 2 3 5 8 GAME 3 4 4 2 4 8 GAME 4 4 5 2 8 GAME 5 3 2 4 4 8 GAME 6 5 5 2 8 GAME 7 2 1 1 4 3 8 GAME 8 3 2 5 2 8 GAME 9 4 2 5 8 GAME 10 3 3 4 3 3 8 GAME 11 4 3 1 3 8 GAME 12 3 4 3 2 8 GAME 13 3 1 2 2 2 8 GAME 14 4 3 1 5 8 GAME 15 5 3 2 1 8 GAME 16 4 5 1 8 GAME 17 5 5 4 8 GAME ...
output:
NRBBNKQR RBBNQKRN BBNQRKNR BBNNRKQR BBRQNKNR NRBBNKQR RNBBQKRN QNRBKNBR RBNNBQKR BBNNQRKR BBRNQKNR NRBBNKQR BNRBNKRQ BBNRKNRQ BBNNQRKR BBRNNKQR NRBBNKQR BNRBNKRQ BBNNRKRQ BQRBNKNR NRBBNKQR RBBNQKRN BBNQRKNR BRNBQKRN BNRBQKNR NRBBNKQR BQRBNNKR NQBBRNKR BNRBNKQR NRBBNKQR RNBBQKRN NRNKBRQB BBNQRKNR BBN...
result:
ok (c) correct after 96 tests, max moves 6 (96 test cases)
Test #11:
score: 0
Accepted
time: 714ms
memory: 3668kb
input:
GAME 1 2 2 3 3 3 8 GAME 2 2 3 4 4 8 GAME 3 2 3 3 3 3 8 GAME 4 1 4 4 3 8 GAME 5 1 3 6 2 8 GAME 6 1 3 4 4 2 8 GAME 7 4 3 3 6 8 GAME 8 3 1 6 5 8 GAME 9 4 3 4 3 8 GAME 10 3 1 3 2 4 8 GAME 11 3 0 3 5 8 GAME 12 2 1 2 5 6 8 GAME 13 5 5 5 8 GAME 14 5 4 0 8 GAME 15 6 1 1 8 GAME 16 4 1 5 3 8 GAME 17 5 3 2 2 8...
output:
NRBBNKQR RNBBQKRN QNRBKNBR BNNQRBKR BBNNQRKR RQNBBNKR NRBBNKQR RNBBQKRN RQKBNNBR QNRBBKNR RNQBBNKR NRBBNKQR RNBBQKRN RQKBNNBR BBRNNQKR BBNNQRKR RNNBBQKR NRBBNKQR BRNNKBQR QNBNRBKR BBNQNRKR RQNNBBKR NRBBNKQR BRNNKBQR RBQNBNKR BBNNRKQR RNQNBBKR NRBBNKQR BRNNKBQR RBQNBNKR BBNQNRKR BBNNRKQR RNNQBBKR NRB...
result:
ok (c) correct after 96 tests, max moves 6 (96 test cases)
Extra Test:
score: 0
Extra Test Passed