QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#196911 | #7179. Fischer's Chess Guessing Game | ucup-team1430 | WA | 370ms | 3928kb | C++20 | 2.5kb | 2023-10-02 04:17:39 | 2023-10-02 04:17:39 |
Judging History
answer
#include <bits/stdc++.h>
#define ff first
#define ss second
#define ll long long
#define ld long double
#define pb push_back
#define endl '\n'
#define sws cin.tie(0)->sync_with_stdio(false);
const int N = 0;
const int INF = 0x3f3f3f3f;
const ll LLINF = 0x3f3f3f3f3f3f3f3f;
using namespace std;
bool is_valid(vector<char> s) {
int n = s.size();
bool ok = true;
int bishop = -1, rook = -1;
for (int i=0;i<n;i++) {
auto c = s[i];
if (c == 'B') {
if (bishop == -1) bishop = i;
else ok &= ((i - bishop) % 2 == 1);
} else if (c == 'R') {
if (rook == -1) rook = i;
else rook = -1;
} else if (c == 'K') {
ok &= (rook != -1);
}
}
return ok;
}
auto dist = [](vector<char> &a, vector<char> &b) {
int qnt = 0;
int n = a.size();
for (int i=0;i<n;i++) {
if (a[i] != b[i]) qnt ++;
}
return qnt;
};
void solve() {
vector<char> pos = {'K', 'Q', 'R', 'R', 'N', 'N', 'B', 'B'};
sort(pos.begin(), pos.end());
vector<vector<char>> p;
do {
p.push_back(pos);
} while (next_permutation(pos.begin(), pos.end()));
vector<vector<char>> p2;
for (auto pi: p) if (is_valid(pi)) p2.push_back(pi);
swap(p, p2);
auto print = [&](vector<char> &x) {
for (auto c: x) cout << c;
cout << endl;
};
auto choose = [](vector<vector<char>> &p) {
int n = p.size();
int id = 0, mx = INF;
for (int i=0;i<n;i++) {
vector<int> dists(10, 0);
for (int j=0;j<n;j++) {
int d = dist(p[i], p[j]);
dists[d] ++;
}
int dmax = 0;
for (auto d: dists) dmax = max(dmax, d);
if (dmax < mx) {
id = i; mx = dmax;
}
}
return id;
};
int it = 6;
while (it --) {
int id = choose(p);
print(p[id]);
cout.flush();
int x; cin >> x;
if (x == 8) { return; }
vector<vector<char>> p2;
for (auto pi: p) {
if (dist(p[id], pi) == 8 - x) {
p2.push_back(pi);
}
}
swap(p, p2);
}
}
int main() {
#ifndef LOCAL
sws;
#endif
string s; int t;
while (cin >> s >> t) {
// if (s == "END") return 0;
solve();
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 5ms
memory: 3856kb
input:
GAME 1 1 2 2 1 2 8 END
output:
NRBBNKQR BNRKQBNR RNBQKRNB BRNQKBRN QNRNBKRB RKRBBQNN
result:
ok (c) correct after 1 tests, max moves 6 (1 test case)
Test #2:
score: -100
Wrong Answer
time: 370ms
memory: 3928kb
input:
GAME 1 1 2 2 1 2 8 GAME 2 2 1 0 1 2 8 GAME 3 1 2 2 0 3 8 GAME 4 1 2 1 1 3 8 GAME 5 2 2 0 3 0 8 GAME 6 2 1 2 1 3 8 GAME 7 0 2 3 4 3 8 GAME 8 1 2 1 0 3 8 GAME 9 0 3 1 2 8 GAME 10 0 3 3 3 8 GAME 11 0 5 3 2 8 GAME 12 1 1 1 4 8 GAME 13 1 2 2 3 4 8 GAME 14 0 4 3 4 8 GAME 15 1 2 1 0 1 8 GAME 16 1 1 3 2 2 8...
output:
NRBBNKQR BNRKQBNR RNBQKRNB BRNQKBRN QNRNBKRB RKRBBQNN NRBBNKQR RBBNKQNR QRKNNRBB NBNRBKRQ BQNBRNKR RKRBBNQN NRBBNKQR BNRKQBNR RNBQKRNB BRNQKBRN RBKNBQNR RKRBBNNQ NRBBNKQR BNRKQBNR RNBQKRNB BBNQRNKR QBRKNRBN RKRBQNBN NRBBNKQR RBBNKQNR NBNQBRKR BRKBRQNN QRBKRNNB RKRBNQBN NRBBNKQR RBBNKQNR QRKNNRBB NRK...
result:
wrong answer (i) too many guesses in game 62, pos = p