QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#491925 | #7179. Fischer's Chess Guessing Game | no_RED_no_DEAD | WA | 1819ms | 3812kb | C++20 | 4.3kb | 2024-07-26 01:24:56 | 2024-07-26 01:24:56 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll N = 1e6 + 1;
const ll M = 1e9 + 7;
string P = "BRKBNQRN";
string Q = "RKRNNBBQ";
string S[5];
ll T[] = {(ll)100, (ll)300, (ll)15000, (ll)10000};
mt19937_64 rng(static_cast<ll>(std::chrono::duration_cast<std::chrono::nanoseconds>(std::chrono::high_resolution_clock::now().time_since_epoch()).count()));
ll rand(ll l, ll r) {
return uniform_int_distribution<ll>(l, r)(rng);
}
ll bruh = 0;
ll val[N];
vector<string> v;
ll cal(string &s, string &t) {
ll res = 0;
for (int i = 0; i <= 7; i ++)
if (s[i] == t[i]) res ++;
return res;
}
ll check(ll x, string &s) {
ll cnt = 0;
for (int i = 0; i < x; i ++) cnt += (1LL << cal(S[i], s)) * 100;
return cnt;
}
void doTest(ll testID) {
for (int _ = 1; _; _ ++) {
while (true) {
bool ok = 0;
shuffle(P.begin(), P.end(), rng);
for (auto x: v)
if (P == x) {ok = 1; break;}
if (ok) break;
}
vector<string> res;
for (auto x: v) res.push_back(x);
for (int i = 0; i <= 2; i ++) {
ll cnt = 1e18, tmp = 0;
for (int j = 0; j < T[i]; j ++) {
string cur = res[rand(0, res.size() - 1)]; tmp = 0;
for (auto y: res) tmp += check(i, cur);
if (tmp < cnt) {cnt = tmp; S[i] = cur;}
}
val[i] = cal(P, S[i]);
vector<string> newRes;
for (auto x: res) if (cal(x, S[i]) == val[i]) newRes.push_back(x);
res = newRes;
cout << "Debug: " << res.size() << endl;
}
for (int i = 3; i <= 3; i ++) {
ll cnt = 0, tmp = 0;
for (int j = 0; j < T[i]; j ++) {
string cur = res[rand(0, res.size() - 1)];
set<ll> s; for (auto y: res) s.insert(cal(cur, y));
if (s.size() > cnt) {cnt = s.size(); S[i] = cur;}
}
val[i] = cal(P, S[i]);
vector<string> newRes;
for (auto x: res) if (cal(x, S[i]) == val[i]) newRes.push_back(x);
res = newRes;
cout << "Debug: " << res.size() << endl;
}
for (int i = 4; i <= 4; i ++) {
ll cnt = 0;
for (auto x: v) {
set<ll> s; for (auto y: res) s.insert(cal(x, y));
if (s.size() > cnt) {cnt = s.size(); S[4] = x;}
}
val[i] = cal(P, S[i]);
vector<string> newRes;
for (auto x: res) if (cal(x, S[i]) == val[i]) newRes.push_back(x);
res = newRes;
cout << "Debug: " << res.size() << endl;
}
string finalRes;
for (auto x: v) {
bool ok = 1;
for (int i = 0; i < 5; i ++)
if (cal(x, S[i]) != cal(P, S[i])) {ok = 0; break;}
if (ok) {
finalRes = x;
break;
}
}
if (finalRes == P) {
cout << "ACCEPTED" << endl; bruh ++;
} else {
cout << "Input: " << ' ' << P << endl;
cout << "S[]: " << S[0] << ' ' << S[1] << ' ' << S[2] << ' ' << S[3] << ' ' << S[4] << endl;
cout << "val[]: " << val[0] << ' ' << val[1] << ' ' << val[2] << ' ' << val[3] << ' ' << val[4] << endl;
cout << "Remain: " << res.size() << endl;
cout << "In Res: "; for (auto x: res) cout << x << ' '; cout << endl;
cout << "Total: " << bruh << endl;
return;
}
}
}
signed main() {
set<string> s;
string T = "KNNBBRRQ";
sort(T.begin(), T.end());
do {
vector<ll> b, r, k;
for (int i = 0; i <= 7; i ++) if (T[i] == 'B') b.push_back(i);
for (int i = 0; i <= 7; i ++) if (T[i] == 'K') k.push_back(i);
for (int i = 0; i <= 7; i ++) if (T[i] == 'R') r.push_back(i);
if ((b[1] - b[0]) % 2 == 0) continue;
if (r[0] > k[0] || r[1] < k[0]) continue;
s.insert(T);
} while(next_permutation(T.begin(), T.end()));
for (auto x: s) v.push_back(x);
shuffle(v.begin(), v.end(), rng);
ios_base::sync_with_stdio(0); cin.tie(0);
int test = 1;
// cin >> test;
for (int _ = 1; _ <= test; _ ++) doTest(test);
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 1819ms
memory: 3812kb
input:
GAME 1
output:
Debug: 177 Debug: 46
result:
wrong answer (i) illegal position "Debug: 177" (game 1, guess 1) (test case 1)