QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#496888 | #7179. Fischer's Chess Guessing Game | ucup-team2307# | TL | 149ms | 3908kb | C++20 | 2.3kb | 2024-07-28 16:45:28 | 2024-07-28 16:45:28 |
Judging History
answer
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
typedef long long ll;
#define int ll
using namespace std;
vector<string> pos;
int ask(int j1, int j2)
{
int ans = 0;
for (int i=0; i<8; i++)
if (pos[j1][i] == pos[j2][i])
ans++;
return ans;
}
int id = 0;
int ask(int id1)
{
cout<<pos[id1]<<endl;
int ans;
cin>>ans;
return ans;
// return ask(id, id1);
}
void solve()
{
vector<int> lt;
for (int i=0; i<960; i++) lt.pb(i);
int cnt = 0;
while (true)
{
pair<int, int> mn = {1e9, -1};
for (int ci=0; ci<min<int>(50, lt.size()); ci++)
{
int i = lt[ci];
vector<int> ans(9);
for (int j : lt)
ans[ask(i, j)]++;
int mx = 0;
for (int j : ans)
mx = max(mx, j);
mn = min(mn, {mx, i});
}
cnt++;
int i = mn.se;
int a = ask(i);
if (a == 8)
break;
vector<int> nw;
for (int j : lt)
if (ask(j, i) == a)
nw.pb(j);
lt = nw;
}
// if (cnt > 6)
// cout<<lt[0]<<" "<<cnt<<"\n";
}
main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
string s = "RQKBBNRN";
sort(s.begin(), s.end());
while (true)
{
int r = 0;
set<int> b;
int id = 0;
bool ok = true;
for (char c : s)
{
id++;
if (c == 'R') r++;
if (c == 'B') b.insert(id%2);
if (c == 'K')
{
if (r!=1)
ok = false;
}
}
if (b.size() != 2)
ok = false;
if (ok)
pos.pb(s);
if (!next_permutation(s.begin(), s.end()))
break;
}
mt19937 rng(56);
shuffle(pos.begin(), pos.end(), rng);
// for (id=0; id<960; id++)
// solve();
// return 0;
while (true)
{
string s;
cin>>s;
if (s == "GAME")
{
int n;
cin>>n;
solve();
}
else
return 0;
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 3ms
memory: 3668kb
input:
GAME 1 3 8 END
output:
RQNBBNKR RKRBBQNN
result:
ok (c) correct after 1 tests, max moves 2 (1 test case)
Test #2:
score: 0
Accepted
time: 142ms
memory: 3908kb
input:
GAME 1 3 8 GAME 2 4 2 6 8 GAME 3 4 2 8 GAME 4 3 5 8 GAME 5 2 0 4 1 8 GAME 6 3 4 2 8 GAME 7 2 1 4 1 8 GAME 8 2 3 0 2 8 GAME 9 2 2 0 8 GAME 10 3 5 4 8 GAME 11 2 1 6 8 GAME 12 3 4 3 5 8 GAME 13 1 2 0 3 8 GAME 14 1 2 1 0 2 8 GAME 15 1 4 1 3 2 8 GAME 16 2 0 3 2 1 8 GAME 17 2 1 4 4 3 8 GAME 18 1 3 3 1 8 G...
output:
RQNBBNKR RKRBBQNN RQNBBNKR NRBBQNKR RKRBBNNQ RKRBBNQN RQNBBNKR NRBBQNKR RKRBBNNQ RQNBBNKR RKRBBQNN RKRBQNBN RQNBBNKR BRNNKBQR RKBBNRNQ RBBKRNNQ RKRBNQBN RQNBBNKR RKRBBQNN RKNQBBRN RKRBNNBQ RQNBBNKR BRNNKBQR RKQNBRNB RQKNNRBB RKRQBBNN RQNBBNKR BRNNKBQR BBQRKNNR NRNKBBRQ RKRNBBQN RQNBBNKR BRNNKBQR NBN...
result:
ok (c) correct after 96 tests, max moves 6 (96 test cases)
Test #3:
score: 0
Accepted
time: 146ms
memory: 3884kb
input:
GAME 1 5 4 3 5 8 GAME 2 5 3 3 3 8 GAME 3 6 4 5 8 GAME 4 4 3 1 6 8 GAME 5 5 5 4 8 GAME 6 4 2 3 8 GAME 7 3 4 4 4 8 GAME 8 4 1 8 GAME 9 4 1 6 4 8 GAME 10 2 3 2 8 GAME 11 3 2 2 1 1 8 GAME 12 3 2 1 8 GAME 13 2 0 2 1 8 GAME 14 3 3 2 4 8 GAME 15 3 3 3 4 8 GAME 16 2 0 1 8 GAME 17 1 3 1 1 1 8 GAME 18 2 0 3 3...
output:
RQNBBNKR RNBBQNKR RNNQBBKR NRQBBNKR RKQBBNNR RQNBBNKR RNBBQNKR QBNRBNKR BQNBNRKR RKNBBQNR RQNBBNKR NQRBBNKR RBNQBNKR RKNBBNQR RQNBBNKR NRBBQNKR QRNNBBKR RNQBKNBR RKQBNNBR RQNBBNKR RNBBQNKR RNKBBNQR RKNBQNBR RQNBBNKR NRBBQNKR RKRBBNNQ RKNBNQBR RQNBBNKR RKRBBQNN RKNQBBRN RQKRBBNN RKQNBBNR RQNBBNKR NRB...
result:
ok (c) correct after 96 tests, max moves 6 (96 test cases)
Test #4:
score: 0
Accepted
time: 133ms
memory: 3696kb
input:
GAME 1 1 0 4 4 8 GAME 2 1 0 3 2 1 8 GAME 3 1 1 4 3 4 8 GAME 4 2 1 3 1 3 8 GAME 5 1 0 4 5 8 GAME 6 2 2 1 3 8 GAME 7 0 1 2 2 8 GAME 8 0 1 3 1 8 GAME 9 0 0 0 8 GAME 10 1 1 4 2 8 GAME 11 1 0 2 1 8 GAME 12 0 0 1 8 GAME 13 1 0 8 GAME 14 2 3 2 0 8 GAME 15 2 2 1 1 1 8 GAME 16 0 4 1 2 8 GAME 17 0 2 8 GAME 18...
output:
RQNBBNKR RBBNNKRQ BRKBRQNN BRKRQNNB QRKRBBNN RQNBBNKR RBBNNKRQ BRKBRQNN BNRBKRQN BRNKQRNB NRKRBBQN RQNBBNKR RBBNNKRQ NRKQNBBR BRQKNBNR NRNKRBBQ NRKRBBNQ RQNBBNKR BRNNKBQR RKQNBRNB RNBBKRNQ NBQRBKNR QRKRBNNB RQNBBNKR RBBNNKRQ BRKBRQNN BRKRQNNB NRKRBQNB RQNBBNKR BRNNKBQR NBNQRKBR RBKNBRQN NRKRBNQB RQN...
result:
ok (c) correct after 96 tests, max moves 6 (96 test cases)
Test #5:
score: 0
Accepted
time: 149ms
memory: 3624kb
input:
GAME 1 3 2 0 1 8 GAME 2 1 1 2 1 8 GAME 3 2 2 3 2 8 GAME 4 4 1 2 4 8 GAME 5 2 0 1 3 8 GAME 6 2 1 2 1 8 GAME 7 1 3 3 8 GAME 8 1 4 3 5 8 GAME 9 1 5 3 3 8 GAME 10 2 0 3 6 8 GAME 11 3 3 3 3 8 GAME 12 3 3 4 4 8 GAME 13 1 3 2 8 GAME 14 2 1 2 0 3 8 GAME 15 2 1 2 0 2 8 GAME 16 2 0 5 3 8 GAME 17 1 2 1 2 3 8 G...
output:
RQNBBNKR RKRBBQNN NRBBNQKR RNKQBNRB RQNKRBBN RQNBBNKR RBBNNKRQ NRKQNBBR BRKNRNQB RNQKRBBN RQNBBNKR BRNNKBQR NBNQRKBR NQNRKRBB RNNKRBBQ RQNBBNKR NRBBQNKR RKNQBBNR RQNBKRBN RQNKRNBB RQNBBNKR BRNNKBQR RKBBNRNQ RBKRQNBN RNQKRNBB RQNBBNKR BRNNKBQR RKQNBRNB NRKQBNRB RNNKRQBB RQNBBNKR RBBNNKRQ RNBNKRQB RBB...
result:
ok (c) correct after 96 tests, max moves 6 (96 test cases)
Test #6:
score: 0
Accepted
time: 139ms
memory: 3696kb
input:
GAME 1 0 1 3 2 8 GAME 2 0 1 4 5 8 GAME 3 0 0 2 4 8 GAME 4 1 3 2 2 4 8 GAME 5 1 2 4 2 8 GAME 6 0 0 3 4 8 GAME 7 2 3 0 6 8 GAME 8 1 1 3 1 3 8 GAME 9 2 3 0 8 GAME 10 3 1 1 4 2 8 GAME 11 2 1 3 0 8 GAME 12 2 2 2 0 1 8 GAME 13 1 1 4 8 GAME 14 2 5 2 8 GAME 15 2 6 4 5 8 GAME 16 1 2 1 3 8 GAME 17 1 1 4 5 8 G...
output:
RQNBBNKR BBRQKRNN NNBRKBRQ BNQRNKRB QRBKNBRN RQNBBNKR BBRQKRNN NNBRKBRQ NRBKRBNQ NRBKQBRN RQNBBNKR BBRQKRNN QNBNRKRB NRKNRBBQ NRBKNBRQ RQNBBNKR RBBNNKRQ RNBNKRQB RBQKNRBN QBBRKNRN QRBKNNRB RQNBBNKR RBBNNKRQ BRQNKNRB BBRQKNRN NRBKQNRB RQNBBNKR BBRQKRNN QNBNRKRB NRKNRQBB NRBKNQRB RQNBBNKR BRNNKBQR BBQ...
result:
ok (c) correct after 96 tests, max moves 6 (96 test cases)
Test #7:
score: -100
Time Limit Exceeded
input:
GAME 1 1 3 4 2 2 8 GAME 2 1 4 4 2 8 GAME 3 1 5 2 3 5 8 GAME 4 1 3 4 5 8 GAME 5 2 2 4 1 5 8 GAME 6 2 3 2 3 4 8 GAME 7 3 4 2 2 8 GAME 8 2 2 0 1 8 GAME 9 2 1 3 8 GAME 10 2 2 0 3 4 8 GAME 11 1 2 2 4 8 GAME 12 1 3 8 GAME 13 4 1 2 8 GAME 14 2 1 3 5 8 GAME 15 3 2 1 3 8 GAME 16 3 1 3 0 8 GAME 17 1 2 4 1 2 8...
output:
RQNBBNKR RBBNNKRQ RNBNKRQB RKQNNRBB QRBNKNRB RBBQKRNN RQNBBNKR RBBNNKRQ NBBNRKQR QBRNNKBR RBBNKRQN RQNBBNKR RBBNNKRQ RNBQNKRB NBRNBKRQ RBKNNRBQ RBBNKRNQ RQNBBNKR RBBNNKRQ RNBNKRQB RKQNNRBB RBQNKRBN RQNBBNKR BRNNKBQR NBNQRKBR NRQBNKBR RKNQRBBN RBNQKRBN RQNBBNKR BRNNKBQR BBQRKNNR RKQNNBBR QBNNRKBR RBN...