QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#195536 | #7179. Fischer's Chess Guessing Game | ucup-team1430 | WA | 7ms | 3896kb | C++14 | 2.2kb | 2023-10-01 05:03:41 | 2023-10-01 05:03:42 |
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;
};
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); // mt19937_64
uniform_int_distribution<int> distribution(1,INF);
void solve() {
vector<char> pos = {'K', 'Q', 'R', 'R', 'N', 'N', 'B', 'B'};
sort(pos.begin(), pos.end());
vector<vector<char>> positions;
do {
positions.push_back(pos);
} while (next_permutation(pos.begin(), pos.end()));
vector<vector<char>> positions2;
for (auto p: positions) if (is_valid(p)) positions2.push_back(p);
swap(positions, positions2);
auto print = [&](vector<char> &x) {
for (auto c: x) cout << c;
cout << endl;
};
int it = 6;
while (it --) {
shuffle(positions.begin(), positions.end(), rng); // shuffle
print(positions[0]);
cout.flush();
int x; cin >> x;
if (x == 8) { return; }
vector<vector<char>> positions2;
for (auto p: positions) {
if (dist(positions[0], p) == 8 - x) {
positions2.push_back(p);
}
}
swap(positions, positions2);
}
}
int main() {
#ifndef LOCAL
sws;
#endif
string s; int t;
while (cin >> s >> t) {
solve();
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3800kb
input:
GAME 1 3 1 3 2 8 END
output:
NBRKBRQN NRBKQRNB RNQKBBRN RBQNKRBN RKRBBQNN
result:
ok (c) correct after 1 tests, max moves 5 (1 test case)
Test #2:
score: -100
Wrong Answer
time: 7ms
memory: 3896kb
input:
GAME 1 0 1 2 1 8 GAME 2 1 2 2 4 4 8 GAME 3 1 4 2 2 8 GAME 4 2 2 0 8 GAME 5 1 2 4 2 8 GAME 6 1 3 2 3 3 8 GAME 7 2 0 5 4 8 GAME 8 0 1 3 2 8 GAME 9 0 2 1 0 8 GAME 10 2 2 0 5 3 8 GAME 11 1 2 3 2 2 1
output:
BBQNRNKR RNNQKRBB NRNBBKRQ NQBRKBRN RKRBBQNN NRKNBBRQ NNRBKQBR RNBQKNRB RQNBBNKR RQKBRNBN RKRBBNQN NRKRNBBQ RKNRBNQB RNNKBBQR RKNNQRBB RKRBBNNQ NRNKQRBB RKNRBQNB QBNNBRKR RKRBQNBN QBBNNRKR BBRKQNRN RKBBRNQN RQBKRBNN RKRBNQBN NRQNKBBR BQRBKNRN QRBBNKRN QBRKRNBN QNRBBNKR RKRBNNBQ BRKNRBQN NRBNQKRB RNK...
result:
wrong answer (i) too many guesses in game 11, pos =