QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#244846 | #7179. Fischer's Chess Guessing Game | std_abs# | RE | 17ms | 3560kb | C++17 | 2.3kb | 2023-11-09 16:30:01 | 2023-11-09 16:30:02 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define pb push_back
#define all(a) a.begin(), a.end()
#define sz(a) ((int)a.size())
const int mod = 998244353, N = 100005;
int main() {
ios::sync_with_stdio(false), cin.tie(0);
vector <string> vec;
{
string s = "KQBBNNRR";
sort(all(s));
do {
int l = 9, r = -1;
for (int i = 0; i < 8; ++i) if (s[i] == 'R') {
l = min(l, i), r = max(r, i);
}
int x = find(all(s), 'K') - s.begin();
if (l <= x && x <= r) {
int l = 9, r = -1;
for (int i = 0; i < 8; ++i) if (s[i] == 'B') {
l = min(l, i), r = max(r, i);
}
if ((r - l) & 1) {
vec.pb(s);
}
}
} while (next_permutation(all(s)));
}
auto dis = [&](string s, string t) {
int ans = 0;
for (int i = 0; i < 8; ++i) {
ans += s[i] == t[i];
}
return ans;
};
auto out = [&](string s) {
cout << s << endl;
int x; cin >> x;
return x;
};
string op;
while (cin >> op) {
if (op == "GAME") {
int _; cin >> _;
vector <string> candidate = vec;
while (candidate.size() > 1) {
pair <int, string> res = {1 << 30, ""};
for (string ask : vec) {
vector <int> cnt(9, 0);
for (string s : candidate) {
cnt[dis(ask, s)]++;
}
int mx = *max_element(all(cnt));
res = min(res, make_pair(mx, ask));
}
string ask = res.second;
int tmp = out(ask);
vector <string> nxt;
for (string s : candidate) {
if (dis(s, ask) == tmp) {
nxt.pb(s);
}
}
candidate = nxt;
}
assert(out(candidate[0]) == 8);
} else if (op == "END") {
break;
} else {
assert(false);
}
}
}
詳細信息
Test #1:
score: 100
Accepted
time: 17ms
memory: 3560kb
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: -100
Runtime Error
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...