QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#366797 | #7179. Fischer's Chess Guessing Game | Giga_Cronos | AC ✓ | 48ms | 7468kb | C++23 | 4.6kb | 2024-03-25 08:28:20 | 2024-03-25 08:28:21 |
Judging History
answer
// #pragma GCC optimize("Ofast,no-stack-protector,unroll-loops", \
// "omit-frame-pointer", "inline")
// #pragma GCC target( \
// "sse,sse2,sse3,ssse3,sse4,sse4.1,sse4.2,popcnt,abm,mmx,avx,avx2,fma,tune=native")
// #pragma GCC option("arch=native", "no-zero-upper") // Enable AVX
/// UH Top
#include <bits/stdc++.h>
#define db(x) cerr << #x << ':' << (x) << '\n';
#define all(v) (v).begin(), (v).end()
#define allr(v) (v).rbegin(), (v).rend()
// #define int ll
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
// typedef __int128_t int128;
typedef pair<ll, ll> pii;
typedef pair<ld, ll> pdi;
typedef pair<ld, ld> pdd;
typedef pair<ld, pdd> pdp;
typedef pair<string, ll> psi;
typedef pair<ll, string> pls;
typedef pair<string, string> pss;
typedef pair<ll, pii> pip;
typedef pair<pii, pii> ppp;
typedef complex<ld> point;
typedef vector<point> polygon;
typedef vector<ll> vi;
typedef pair<point, int> ppi;
#define prec(n) \
cout.precision(n); \
cout << fixed
const ll mod = (1e9 + 7);
const ld eps = (1e-9);
const ll oo = (ll)(1e9 + 5);
#define pi acos(-1)
#define MAXN (ll)(1e6 + 5)
vector<string> gen() {
vector<int> av;
for (int i = 0; i < 8; i++)
av.push_back(i);
vector<pii> bb;
for (int i = 0; i < 8; i += 2)
for (int j = 1; j < 8; j += 2)
bb.push_back(pii(i, j));
vector<pip> rkr;
for (int i = 0; i < 6; i++)
for (int j = i + 1; j < 6; j++)
for (int k = j + 1; k < 6; k++)
rkr.push_back(pip(i, pii(j, k)));
// cout << bb.size() << ' ' << rkr.size() << "\n";
string sssss = "RKR";
vector<string> rem = {"QNN", "NQN", "NNQ"};
vector<string> ans;
for (auto b : bb) {
for (auto p : rkr) {
vector<int> nav;
string x(8, ' ');
for (int i = 0; i < 8; i++) {
if (i != b.first && i != b.second) {
nav.push_back(i);
} else {
x[i] = 'B';
}
}
// cout << nav.size() << "\n";
// cout << p.first << ' ' << p.second.first << ' ' <<
// p.second.second << "\n";
vector<int> nnav;
int cont = 0;
for (int i = 0; i < 6; i++) {
int pos = nav[i];
// cout << nav[i] << "\n";
if (i != p.first && i != p.second.first &&
i != p.second.second) {
nnav.push_back(pos);
} else {
x[pos] = sssss[cont];
cont++;
// cout << pos << ' ' << cont << "\n";
}
}
for (int j = 0; j < 3; j++) {
for (int i = 0; i < 3; i++) {
x[nnav[i]] = rem[j][i];
}
// cout << x << "\n";
ans.push_back(x);
}
// break;
}
// break;
}
return ans;
}
int eqs[960][960];
int32_t main() {
// ios_base::sync_with_stdio(0);
// cin.tie(0);
vector<string> ip = gen();
// cout << ip.size() << "\n";
int sz = 960;
for (int i = 0; i < sz; i++)
for (int j = 0; j < sz; j++)
for (int k = 0; k < 8; k++)
eqs[i][j] += (ip[i][k] == ip[j][k]);
int best = 0;
int cant = 960;
for (int i = 0; i < 960; i++) {
vector<int> f(9);
for (int j = 0; j < 960; j++)
f[eqs[i][j]]++;
int ma = 0;
for (int j = 0; j < 9; j++)
ma = max(ma, f[j]);
if (ma < cant) {
cant = ma;
best = i;
}
}
string xxxx = "RKRBBQNN";
// for (int i = 0; i < 960; i++)
// if (ip[i] == xxxx)
// cout << "xxx: " << i << "\n";
auto ask = [&](int i) {
cout << ip[i] << "\n";
cout.flush();
int r = 0;
cin >> r;
// for (int j = 0; j < 8; j++)
// r += (xxxx[j] == ip[i][j]);
// cout << r << "\n";
return r;
};
vector<int> precs[9];
for (int i = 0; i < 960; i++)
precs[eqs[best][i]].push_back(i);
// cout << best << "\n";
string s;
cin >> s;
while (s != "END") {
int _;
cin >> _;
int cant = ask(best);
vector<int> act = precs[cant];
int cont = 0;
while (cant != 8) {
int best = 0;
cant = 960;
for (int i = 0; i < 960; i++) {
vector<int> f(9);
for (auto p : act)
f[eqs[i][p]]++;
int ma = 0;
for (int j = 0; j < 9; j++)
ma = max(ma, f[j]);
if (ma < cant || (cant==ma && f[8]==1)) {
cant = ma;
best = i;
}
}
vector<int> precs[9];
for (auto i : act)
precs[eqs[best][i]].push_back(i);
cant = ask(best);
act = precs[cant];
// cout << cant << "\n";
// cout << act.size() << "\n";
// cont++;
// for (auto i : act)
// cout << i << ' ';
// cout << "\n";
// if (cont == 10)
// break;
}
cin >> s;
// s = "END";
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 4ms
memory: 7204kb
input:
GAME 1 1 0 3 6 8 END
output:
NRBBNKQR BRNNKBQR NQRKBRNB RKQBBRNN RKRBBQNN
result:
ok (c) correct after 1 tests, max moves 5 (1 test case)
Test #2:
score: 0
Accepted
time: 43ms
memory: 7196kb
input:
GAME 1 1 0 3 6 8 GAME 2 2 3 3 2 3 8 GAME 3 1 0 3 5 5 8 GAME 4 1 0 1 2 8 GAME 5 2 3 4 2 8 GAME 6 2 2 4 2 8 GAME 7 0 2 3 3 8 GAME 8 1 3 3 5 8 GAME 9 0 3 1 1 8 GAME 10 0 3 3 3 8 GAME 11 0 5 2 8 GAME 12 1 2 2 0 8 GAME 13 1 1 5 4 8 GAME 14 0 4 2 4 8 GAME 15 1 2 1 1 8 GAME 16 1 0 2 5 5 8 GAME 17 0 5 4 8 G...
output:
NRBBNKQR BRNNKBQR NQRKBRNB RKQBBRNN RKRBBQNN NRBBNKQR RNBBQKRN RQKBNNBR RBBKQNNR RNNBBQKR RKRBBNQN NRBBNKQR BRNNKBQR NQRKBRNB RKQBBRNN RNKBBRNQ RKRBBNNQ NRBBNKQR BRNNKBQR NQRKBRNB RNKBBQNR RKRBQNBN NRBBNKQR RNBBQKRN RQKBNNBR QNRBBKNR RKRBNQBN NRBBNKQR RNBBQKRN QNRBKNBR QRNBKRBN RKRBNNBQ NRBBNKQR RKN...
result:
ok (c) correct after 96 tests, max moves 6 (96 test cases)
Test #3:
score: 0
Accepted
time: 43ms
memory: 7256kb
input:
GAME 1 2 2 3 3 8 GAME 2 2 2 2 3 4 8 GAME 3 3 1 3 1 8 GAME 4 3 1 2 3 3 8 GAME 5 2 3 5 5 8 GAME 6 3 1 1 2 8 GAME 7 1 3 5 8 GAME 8 1 3 3 4 8 GAME 9 2 1 3 2 8 GAME 10 2 1 0 8 GAME 11 2 1 1 3 8 GAME 12 1 4 3 2 8 GAME 13 0 2 3 3 4 8 GAME 14 1 1 2 4 2 8 GAME 15 0 1 0 5 8 GAME 16 0 2 2 3 8 GAME 17 1 0 0 4 8...
output:
NRBBNKQR RNBBQKRN QNRBKNBR BQNBRKNR RKQBBNNR NRBBNKQR RNBBQKRN QNRBKNBR RKBNNBQR RKNBNRBQ RKNBBQNR NRBBNKQR RBBNQKRN BRKBRNQN BBRKNQNR RKNBBNQR NRBBNKQR RBBNQKRN BRKBRNQN QRKNNBBR QNNBRKBR RKQBNNBR NRBBNKQR RNBBQKRN RQKBNNBR RNQBKNBR RKNBQNBR NRBBNKQR RBBNQKRN BRKBRNQN NRQNKBBR RKNBNQBR NRBBNKQR BRN...
result:
ok (c) correct after 96 tests, max moves 6 (96 test cases)
Test #4:
score: 0
Accepted
time: 45ms
memory: 7232kb
input:
GAME 1 1 2 1 5 8 GAME 2 3 1 4 1 8 GAME 3 2 0 3 0 8 GAME 4 1 1 0 4 8 GAME 5 2 0 4 4 8 GAME 6 3 0 1 1 8 GAME 7 2 1 1 0 8 GAME 8 2 2 1 1 8 GAME 9 3 0 0 8 GAME 10 2 0 4 8 GAME 11 2 1 3 1 8 GAME 12 3 0 0 6 8 GAME 13 2 2 1 0 4 8 GAME 14 3 1 8 GAME 15 2 1 1 3 0 8 GAME 16 1 3 0 4 8 GAME 17 2 1 2 5 5 8 GAME ...
output:
NRBBNKQR BRNNKBQR BNRBKRQN QRKNBRNB QRKRBBNN NRBBNKQR RBBNQKRN BRKBRNQN QNRBBNKR NRKRBBQN NRBBNKQR RNBBQKRN BRKQNRNB BBQNNRKR NRKRBBNQ NRBBNKQR BRNNKBQR RKQNRBBN QNNRBKRB QRKRBNNB NRBBNKQR RNBBQKRN BRKQNRNB QRKRNNBB NRKRBQNB NRBBNKQR RBBNQKRN BNRBQNKR QRNKNBBR NRKRBNQB NRBBNKQR RNBBQKRN NRNKBRQB BBN...
result:
ok (c) correct after 96 tests, max moves 6 (96 test cases)
Test #5:
score: 0
Accepted
time: 39ms
memory: 7228kb
input:
GAME 1 0 4 1 8 GAME 2 0 3 4 2 8 GAME 3 0 4 2 3 8 GAME 4 0 5 8 GAME 5 0 4 2 2 8 GAME 6 0 6 0 8 GAME 7 1 0 3 4 8 GAME 8 3 4 3 3 8 GAME 9 2 2 0 0 5 8 GAME 10 0 1 1 5 8 GAME 11 1 2 3 4 8 GAME 12 0 2 3 5 8 GAME 13 1 0 2 4 8 GAME 14 0 3 2 1 8 GAME 15 1 1 2 2 8 GAME 16 2 2 0 1 8 GAME 17 1 0 4 3 8 GAME 18 3...
output:
NRBBNKQR RKNNRQBB RBKNBNRQ RQNKRBBN NRBBNKQR RKNNRQBB QNRKRNBB QNNRKRBB RNQKRBBN NRBBNKQR RKNNRQBB RBKNBNRQ BNRKQBRN RNNKRBBQ NRBBNKQR RKNNRQBB RQNKRNBB NRBBNKQR RKNNRQBB RBKNBNRQ BNRKQBRN RNQKRNBB NRBBNKQR RKNNRQBB BRKNNBRQ RNNKRQBB NRBBNKQR BRNNKBQR NQRKBRNB RKQBBRNN RBBKQRNN NRBBNKQR RBBNQKRN RBQ...
result:
ok (c) correct after 96 tests, max moves 6 (96 test cases)
Test #6:
score: 0
Accepted
time: 43ms
memory: 7240kb
input:
GAME 1 3 3 2 2 2 8 GAME 2 3 4 0 8 GAME 3 4 1 6 8 GAME 4 3 2 2 0 8 GAME 5 3 3 4 3 8 GAME 6 4 1 8 GAME 7 1 3 1 2 8 GAME 8 2 2 0 4 8 GAME 9 2 1 5 5 8 GAME 10 1 2 0 3 8 GAME 11 2 1 5 8 GAME 12 2 1 6 5 8 GAME 13 3 0 2 4 8 GAME 14 2 1 3 5 3 8 GAME 15 4 3 2 1 8 GAME 16 4 4 4 2 8 GAME 17 4 3 4 8 GAME 18 6 0...
output:
NRBBNKQR RBBNQKRN NRQNBKRB QBRNNKBR RKBNNRQB QRBKNBRN NRBBNKQR RBBNQKRN RBQNNKBR NRBKQBRN NRBBNKQR QRNBBKNR NRBKNQRB NRBKNBRQ NRBBNKQR RBBNQKRN RQBBKNNR NBQRBKNR QRBKNNRB NRBBNKQR RBBNQKRN NRQNBKRB QRKBBNRN NRBKQNRB NRBBNKQR QRNBBKNR NRBKNQRB NRBBNKQR BRNNKBQR RBQNBNKR BNRKQBNR QRNKBBRN NRBBNKQR RNB...
result:
ok (c) correct after 96 tests, max moves 6 (96 test cases)
Test #7:
score: 0
Accepted
time: 43ms
memory: 7188kb
input:
GAME 1 1 1 2 6 8 GAME 2 2 3 1 0 5 8 GAME 3 1 2 2 1 4 8 GAME 4 0 3 1 6 8 GAME 5 0 3 1 8 GAME 6 0 4 4 8 GAME 7 2 4 2 1 8 GAME 8 3 3 0 4 8 GAME 9 2 4 3 3 8 GAME 10 1 2 2 0 3 8 GAME 11 1 1 1 8 GAME 12 2 3 1 2 8 GAME 13 1 2 4 6 8 GAME 14 1 1 4 1 8 GAME 15 1 2 4 8 GAME 16 0 5 5 8 GAME 17 0 4 2 1 8 GAME 18...
output:
NRBBNKQR BRNNKBQR RKQNRBBN RBBQKNRN RBBQKRNN NRBBNKQR RNBBQKRN RQKBNNBR BNRQNKRB RKBNRBQN RBBNKRQN NRBBNKQR BRNNKBQR BNRBKRQN BBNQRKRN RNBNKQRB RBBNKRNQ NRBBNKQR RKNNRQBB QNRKRNBB RBNQKRBN RBQNKRBN NRBBNKQR RKNNRQBB QNRKRNBB RBNQKRBN NRBBNKQR RKNNRQBB RBKNBNRQ RBNNKRBQ NRBBNKQR RNBBQKRN RNBKNBQR QNB...
result:
ok (c) correct after 96 tests, max moves 6 (96 test cases)
Test #8:
score: 0
Accepted
time: 48ms
memory: 7468kb
input:
GAME 1 3 0 3 3 8 GAME 2 4 3 2 5 8 GAME 3 4 4 4 8 GAME 4 2 0 1 2 8 GAME 5 3 1 1 8 GAME 6 3 0 1 5 8 GAME 7 0 0 2 4 8 GAME 8 1 4 1 5 8 GAME 9 0 1 5 4 8 GAME 10 1 2 6 6 8 GAME 11 2 3 1 3 8 GAME 12 1 2 6 8 GAME 13 0 2 1 4 8 GAME 14 0 1 6 8 GAME 15 1 4 2 3 8 GAME 16 0 2 1 8 GAME 17 1 1 2 4 8 GAME 18 1 2 3...
output:
NRBBNKQR RBBNQKRN BNRBQNKR BRKBRNNQ QRNBKNBR NRBBNKQR QRNBBKNR RNBQKBNR NNQBRKBR NRQBKNBR NRBBNKQR QRNBBKNR NRNKBBQR NRNBKQBR NRBBNKQR RNBBQKRN BRKQNRNB BBRQKNNR QRNNKBBR NRBBNKQR RBBNQKRN BRKBRNQN NRQNKBBR NRBBNKQR RBBNQKRN BNRBQNKR QRNKNBBR NRNQKBBR NRBBNKQR RKNNRQBB QNRKBBRN BBQRKNRN BBRQKRNN NRB...
result:
ok (c) correct after 96 tests, max moves 6 (96 test cases)
Test #9:
score: 0
Accepted
time: 29ms
memory: 7256kb
input:
GAME 1 2 1 0 1 8 GAME 2 3 2 4 5 8 GAME 3 4 1 2 6 8 GAME 4 1 3 3 1 8 GAME 5 2 0 0 8 GAME 6 2 0 0 6 8 GAME 7 2 2 4 2 0 8 GAME 8 3 1 0 4 8 GAME 9 4 1 2 8 GAME 10 1 4 4 5 8 GAME 11 2 0 0 5 8 GAME 12 2 1 1 1 8 GAME 13 3 6 5 5 8 GAME 14 2 6 2 4 8 GAME 15 3 6 4 5 8 GAME 16 1 1 4 1 3 8 GAME 17 1 1 2 5 8 GAM...
output:
NRBBNKQR RNBBQKRN NRNKBRQB RKQNNBBR QBBRKNNR NRBBNKQR RBBNQKRN RQBBKNNR QBBRKRNN NBBRKQNR NRBBNKQR QRNBBKNR NRBKNQRB NNBRKBQR NBBRKNQR NRBBNKQR BRNNKBQR RBQNBNKR RKNNBRQB QBNRKNBR NRBBNKQR RNBBQKRN BRKQNRNB NBQRKNBR NRBBNKQR RNBBQKRN BRKQNRNB NBQRKNBR NBNRKQBR NRBBNKQR RNBBQKRN QNRBKNBR QRNBKRBN RKR...
result:
ok (c) correct after 96 tests, max moves 6 (96 test cases)
Test #10:
score: 0
Accepted
time: 40ms
memory: 7212kb
input:
GAME 1 3 2 2 4 8 GAME 2 2 2 2 2 8 GAME 3 4 2 1 2 8 GAME 4 4 4 1 4 8 GAME 5 3 2 3 0 8 GAME 6 5 5 2 8 GAME 7 2 1 1 4 8 GAME 8 3 2 2 6 8 GAME 9 4 3 1 1 8 GAME 10 3 3 2 8 GAME 11 4 2 2 3 8 GAME 12 3 4 5 8 GAME 13 3 1 1 1 8 GAME 14 4 5 4 8 GAME 15 5 3 3 8 GAME 16 4 4 1 2 8 GAME 17 5 5 3 8 GAME 18 4 3 2 6...
output:
NRBBNKQR RBBNQKRN RQBBKNNR NBQRBKNR BBRQNKNR NRBBNKQR RNBBQKRN QNRBKNBR RKBNNBQR BBRNQKNR NRBBNKQR QRNBBKNR NNBBRKRQ NRKQNBBR BBRNNKQR NRBBNKQR QRNBBKNR NRNKBBQR BBRKNRNQ BQRBNKNR NRBBNKQR RBBNQKRN RQBBKNNR RKBRNNQB BNRBQKNR NRBBNKQR BQRBNNKR NRBBQNKR BNRBNKQR NRBBNKQR RNBBQKRN NRNKBRQB BBNQRKNR QBR...
result:
ok (c) correct after 96 tests, max moves 6 (96 test cases)
Test #11:
score: 0
Accepted
time: 37ms
memory: 7244kb
input:
GAME 1 2 2 3 4 8 GAME 2 2 3 4 4 8 GAME 3 2 3 3 2 8 GAME 4 1 4 4 4 8 GAME 5 1 3 6 0 8 GAME 6 1 3 4 1 8 GAME 7 4 3 1 8 GAME 8 3 1 4 4 8 GAME 9 4 4 3 4 8 GAME 10 3 1 2 5 8 GAME 11 3 0 3 2 8 GAME 12 2 1 2 3 8 GAME 13 5 5 6 8 GAME 14 5 4 4 8 GAME 15 6 1 8 GAME 16 4 3 3 5 8 GAME 17 5 3 4 8 GAME 18 4 2 2 0...
output:
NRBBNKQR RNBBQKRN QNRBKNBR BQNBRKNR RQNBBNKR NRBBNKQR RNBBQKRN RQKBNNBR QNRBBKNR RNQBBNKR NRBBNKQR RNBBQKRN RQKBNNBR RBBKQNNR RNNBBQKR NRBBNKQR BRNNKBQR QNBNRBKR RNQNKBBR RQNNBBKR NRBBNKQR BRNNKBQR RBQNBNKR BBRKRQNN RNQNBBKR NRBBNKQR BRNNKBQR RBQNBNKR QBRNKNBR RNNQBBKR NRBBNKQR QRNBBKNR RNBQKBNR BRQ...
result:
ok (c) correct after 96 tests, max moves 6 (96 test cases)
Extra Test:
score: 0
Extra Test Passed