QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#491846 | #7179. Fischer's Chess Guessing Game | no_RED_no_DEAD | TL | 0ms | 0kb | C++20 | 2.2kb | 2024-07-25 23:16:10 | 2024-07-25 23:16:11 |
answer
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll N = 1e6 + 1;
const ll M = 1e9 + 7;
const ll T = 50;
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);
}
string S[5];
vector<string> v, res;
ll val[N];
ll cal(string &s, string &t) {
ll res = 0;
for (int i = 0; i <= 7; i ++)
if (s[i] == t[i]) res ++;
return res;
}
void doTest(ll testID) {
while (true) {
bool nxt = 0;
string tmp; cin >> tmp;
if (tmp == "END") return;
cin >> tmp;
res.clear();
for (auto x: v) res.push_back(x);
for (int i = 0; i <= 4; i ++) {
ll cnt = 0, tmp = 0;
for (int j = 1; j <= T; j ++) {
string cur = v[rand(0, v.size() - 1)]; tmp = 0;
set<ll> s; for (auto y: res) if (cal(y, S[i]) == cal(cur, S[i])) tmp ++;
if (s.size() < cnt) {cnt = s.size(); S[i] = cur;}
}
cout << S[i] << endl;
cin >> val[i]; if (val[i] == 8) {nxt = 1; break;}
vector<string> newRes;
for (auto x: res) if (cal(x, S[i]) == val[i]) newRes.push_back(x);
res = newRes;
}
if (nxt) continue;
cout << res[0] << endl;
cin >> val[4];
}
}
signed main() {
// freopen("a.inp", "r", stdin);
// freopen("a.out", "w", stdout);
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);
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
Time Limit Exceeded
input:
GAME 1