QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#172001#7179. Fischer's Chess Guessing Gameucup-team1069#AC ✓152ms3932kbC++202.9kb2023-09-09 17:56:082023-09-09 17:56:10

Judging History

你现在查看的是最新测评结果

  • [2023-09-09 17:56:10]
  • 评测
  • 测评结果:AC
  • 用时:152ms
  • 内存:3932kb
  • [2023-09-09 17:56:08]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;

#define sz(x) (int)x.size()

bool check(string s) {
    vector<int> was[30];
    for (int i = 0; i < sz(s); ++i) {
        was[s[i] - 'A'].push_back(i);
    }
    if (was['R' - 'A'][0] > was['K' - 'A'][0] || was['K' - 'A'][0] > was['R' - 'A'][1]) {
        return 0;
    }
    if ((was['B' - 'A'][0] + was['B' - 'A'][1]) % 2 == 0) {
        return 0;
    }
    return 1;
}

int get(string s, string t) {
    int ans = 0;
    for (int i = 0; i < sz(s); ++i)
        if (s[i] == t[i]) ans++;
    return ans;
}

vector<string> v;

string find(set<string> p) {
    int was[20];
    int mx = 100;
    string t;
    for (auto i : p) {
        for (int j = 0; j <= 10; ++j) was[j] = 0;
        for (auto j : p) {
            was[get(i, j)]++;
        }
        int now = 0;
        for (int j = 0; j <= 8; ++j) now = max(now, was[j]);
        if (now < mx) {
            mx = now;
            t = i;
        }
    }
    return t;
}
/*
int solve(string T, int st = 0) {
    string s;
    vector<string> p;
    s = v[st];
    s = "BBNRKNRQ";
    int ans = 1;
    int k = get(s, T);

    if (k == 8) {
        return 1;
    }
    for (auto i : v) {
        if (get(i, s) == k) {
            p.push_back(i);
        }
    }
    while (p.size() > 1) {
        s = find(p);
        ans++;
        k = get(s, T);
        if (k == 8) {
            return ans;
        }
        vector<string> pp;
        for (auto i : v) {
            if (find(p.begin(), p.end(), i) != p.end() && get(i, s) == k) {
                pp.push_back(i);
            }
        }
        p = pp;
    }
    ans++;
    return ans;
}
*/
int make(string T = "") {

    set<string> p;
    string s = "BBNRKNRQ";
    cout << s << endl;
    int ans = 1;
    int k;
    if (T == "")
        cin >> k;
    else 
        k = get(s, T);
    if (k == 8) return ans;

    for (auto i : v) {
        if (get(i, s) == k) {
            p.insert(i);
        }
    }
    while (p.size() > 1) {
        s = find(p);
        cout << s << endl;
        ans++;
        if (T == "")
            cin >> k;
        else 
            k = get(s, T);
        if (k == 8) {
            return ans;
        }
        set<string> pp;
        for (auto i : v) {
            if (p.count(i) && get(i, s) == k) {
                pp.insert(i);
            }
        }
        p = pp;
    }
    cout << *p.begin() << endl;
    if (T == "")
        cin >> k;
    else 
        k = get(s, T);
    return ans;
}

int main() {
    string s = "RQKBBNRN";
    sort(s.begin(), s.end());
    while (true) {
        if (check(s)) v.push_back(s);
        if (!next_permutation(s.begin(), s.end())) break;
    }
    string g;
    int n;
    while (true) {
        cin >> g;
        if (g == "END") break;
        cin >> n;
        make();
    }
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 3ms
memory: 3716kb

input:

GAME 1
0
0
6
8
END

output:

BBNRKNRQ
NRBNQBKR
RKQBBRNN
RKRBBQNN

result:

ok (c) correct after 1 tests, max moves 4 (1 test case)

Test #2:

score: 0
Accepted
time: 152ms
memory: 3868kb

input:

GAME 1
0
0
6
8
GAME 2
1
6
4
4
8
GAME 3
2
2
1
1
0
8
GAME 4
1
4
4
6
8
GAME 5
0
0
4
8
GAME 6
2
1
0
2
1
8
GAME 7
0
1
1
3
8
GAME 8
0
2
3
1
8
GAME 9
1
3
3
4
8
GAME 10
1
3
3
3
8
GAME 11
0
1
3
1
8
GAME 12
1
4
2
2
4
8
GAME 13
0
1
3
5
8
GAME 14
0
3
2
0
8
GAME 15
1
2
1
2
2
8
GAME 16
1
2
1
1
1
8
GAME 17
1
2
2
2...

output:

BBNRKNRQ
NRBNQBKR
RKQBBRNN
RKRBBQNN
BBNRKNRQ
RKNBBRQN
RKNBQRBN
RKNNBRQB
RKRBBNQN
BBNRKNRQ
QBRNBKRN
BNRKNQRB
RBNQNKBR
NRBQKBRN
RKRBBNNQ
BBNRKNRQ
RKNBBRQN
RKBBNQRN
RKQBRNBN
RKRBQNBN
BBNRKNRQ
NRBNQBKR
RKQBBRNN
RKRBNQBN
BBNRKNRQ
QBRNBKRN
BQNNRBKR
RNKRBNQB
NRBKQNRB
RKRBNNBQ
BBNRKNRQ
NRBNQBKR
RQKNNRBB
QNR...

result:

ok (c) correct after 96 tests, max moves 6 (96 test cases)

Test #3:

score: 0
Accepted
time: 151ms
memory: 3700kb

input:

GAME 1
1
4
3
2
8
GAME 2
1
5
2
8
GAME 3
2
1
2
2
1
8
GAME 4
1
3
5
3
8
GAME 5
2
0
4
1
4
8
GAME 6
1
4
5
3
8
GAME 7
0
3
4
2
8
GAME 8
1
4
2
4
8
GAME 9
1
5
4
8
GAME 10
0
3
4
1
8
GAME 11
1
3
8
GAME 12
1
3
6
8
GAME 13
2
3
3
1
3
8
GAME 14
3
2
1
4
8
GAME 15
4
2
2
1
8
GAME 16
3
3
0
3
3
8
GAME 17
2
2
2
0
0
8
GAM...

output:

BBNRKNRQ
RKNBBRQN
RKBBNQRN
RKNQRBBN
RKQBBNNR
BBNRKNRQ
RKNBBRQN
RBKNBRQN
RKNBBQNR
BBNRKNRQ
QBRNBKRN
BQNNRBKR
BNRKRNQB
BRKRNBQN
RKNBBNQR
BBNRKNRQ
RKNBBRQN
RKNQNBBR
RKBQNBRN
RKQBNNBR
BBNRKNRQ
QBRNBKRN
BRKBQNNR
BRQKRNNB
BNNBQRKR
RKNBQNBR
BBNRKNRQ
RKNBBRQN
RKBBNQRN
RKBRNBQN
RKNBNQBR
BBNRKNRQ
NRBNQBKR
RQB...

result:

ok (c) correct after 96 tests, max moves 6 (96 test cases)

Test #4:

score: 0
Accepted
time: 152ms
memory: 3932kb

input:

GAME 1
1
2
1
3
2
8
GAME 2
1
3
1
1
5
8
GAME 3
2
1
1
8
GAME 4
2
2
1
0
8
GAME 5
1
1
2
3
4
8
GAME 6
2
1
0
6
8
GAME 7
1
1
3
3
1
8
GAME 8
1
1
3
2
8
GAME 9
2
0
2
1
8
GAME 10
2
1
0
4
8
GAME 11
2
0
4
3
8
GAME 12
1
0
0
5
8
GAME 13
1
2
2
0
8
GAME 14
2
1
2
4
8
GAME 15
3
3
5
8
GAME 16
1
1
6
5
8
GAME 17
1
2
1
2
8...

output:

BBNRKNRQ
RKNBBRQN
NRNBQKBR
NQRKBBRN
QBRKNRBN
QRKRBBNN
BBNRKNRQ
RKNBBRQN
RKNQNBBR
QNRBKRBN
NRKBBNQR
NRKRBBQN
BBNRKNRQ
QBRNBKRN
BQNNRBKR
NRKRBBNQ
BBNRKNRQ
QBRNBKRN
BNRKNQRB
RBNQNKBR
QRKRBNNB
BBNRKNRQ
RKNBBRQN
BRQKRBNN
NRQNKRBB
NRBBKQNR
NRKRBQNB
BBNRKNRQ
QBRNBKRN
BQNNRBKR
RNKRBNQB
NRKRBNQB
BBNRKNRQ
RKN...

result:

ok (c) correct after 96 tests, max moves 6 (96 test cases)

Test #5:

score: 0
Accepted
time: 146ms
memory: 3704kb

input:

GAME 1
1
3
4
5
8
GAME 2
0
1
2
4
8
GAME 3
2
0
0
1
8
GAME 4
2
0
1
0
3
8
GAME 5
1
1
3
0
8
GAME 6
1
2
2
1
3
8
GAME 7
1
3
1
2
3
8
GAME 8
1
4
4
2
8
GAME 9
2
1
0
1
2
8
GAME 10
1
4
2
6
8
GAME 11
2
3
4
8
GAME 12
3
3
4
2
8
GAME 13
1
3
3
2
8
GAME 14
2
2
1
4
1
8
GAME 15
3
2
0
2
8
GAME 16
0
1
5
5
8
GAME 17
0
2
1...

output:

BBNRKNRQ
RKNBBRQN
RKNQNBBR
RQNKBBNR
RQNKRBBN
BBNRKNRQ
NRBNQBKR
RQKNNRBB
NNRKRQBB
RNQKRBBN
BBNRKNRQ
QBRNBKRN
BRKBQNNR
NNBRKRQB
RNNKRBBQ
BBNRKNRQ
QBRNBKRN
BRKBQNNR
NNBRKBQR
RKNBNRBQ
RQNKRNBB
BBNRKNRQ
RKNBBRQN
BRQKRBNN
BRKBNQNR
RNQKRNBB
BBNRKNRQ
RKNBBRQN
NRNBQKBR
RBBNNKQR
RNKRQBBN
RNNKRQBB
BBNRKNRQ
RKN...

result:

ok (c) correct after 96 tests, max moves 6 (96 test cases)

Test #6:

score: 0
Accepted
time: 144ms
memory: 3592kb

input:

GAME 1
1
1
4
6
8
GAME 2
1
1
4
8
GAME 3
2
1
1
4
8
GAME 4
2
2
4
3
4
8
GAME 5
2
1
0
2
8
GAME 6
1
0
1
8
GAME 7
2
4
0
5
8
GAME 8
1
2
2
0
2
8
GAME 9
3
1
1
5
8
GAME 10
3
2
1
3
8
GAME 11
2
2
3
0
3
8
GAME 12
2
2
4
3
8
GAME 13
1
0
5
5
8
GAME 14
2
0
5
3
8
GAME 15
2
0
3
0
8
GAME 16
0
4
2
5
8
GAME 17
0
6
5
4
8
G...

output:

BBNRKNRQ
RKNBBRQN
BRQKRBNN
NRBKQBRN
QRBKNBRN
BBNRKNRQ
RKNBBRQN
BRQKRBNN
NRBKQBRN
BBNRKNRQ
QBRNBKRN
BQNNRBKR
NRKRBBNQ
NRBKNBRQ
BBNRKNRQ
QBRNBKRN
BNRKNQRB
BRKBNQRN
NRNKBQRB
QRBKNNRB
BBNRKNRQ
QBRNBKRN
BQNNRBKR
RNKRBNQB
NRBKQNRB
BBNRKNRQ
RKNBBRQN
BNRKQBNR
NRBKNQRB
BBNRKNRQ
QBRNBKRN
BBRNNKQR
QRKBBNRN
QRN...

result:

ok (c) correct after 96 tests, max moves 6 (96 test cases)

Test #7:

score: 0
Accepted
time: 137ms
memory: 3676kb

input:

GAME 1
2
2
0
0
8
GAME 2
2
3
3
1
8
GAME 3
3
2
1
0
8
GAME 4
2
3
3
2
3
8
GAME 5
3
1
4
2
8
GAME 6
4
2
3
4
8
GAME 7
1
4
4
3
8
GAME 8
1
5
4
2
8
GAME 9
2
0
2
1
1
8
GAME 10
1
2
0
0
4
8
GAME 11
1
2
0
1
3
8
GAME 12
1
3
1
3
3
8
GAME 13
2
1
2
0
0
8
GAME 14
1
4
3
3
8
GAME 15
3
0
4
2
8
GAME 16
2
1
3
0
8
GAME 17
1...

output:

BBNRKNRQ
QBRNBKRN
BNRKNQRB
QRNBBNKR
RBBQKRNN
BBNRKNRQ
QBRNBKRN
BBRKQRNN
QBRKNNBR
RBBNKRQN
BBNRKNRQ
BBRKQNNR
BNRQKBRN
BRKRNNQB
RBBNKRNQ
BBNRKNRQ
QBRNBKRN
BBRKQRNN
QBRKNNBR
BBQNRKNR
RBQNKRBN
BBNRKNRQ
BBRKQNNR
NBBRKRQN
NBQRBKRN
RBNQKRBN
BBNRKNRQ
NRBBKNRQ
BBRNNKRQ
RBKRNNBQ
RBNNKRBQ
BBNRKNRQ
RKNBBRQN
RKB...

result:

ok (c) correct after 96 tests, max moves 6 (96 test cases)

Test #8:

score: 0
Accepted
time: 87ms
memory: 3704kb

input:

GAME 1
3
2
1
2
8
GAME 2
2
0
4
3
4
8
GAME 3
2
0
3
1
3
8
GAME 4
2
2
0
4
5
8
GAME 5
1
0
2
2
3
8
GAME 6
2
0
2
4
8
GAME 7
3
4
3
4
8
GAME 8
3
3
1
8
GAME 9
4
2
5
5
8
GAME 10
2
2
2
1
1
8
GAME 11
2
2
3
8
GAME 12
3
3
3
1
8
GAME 13
2
2
3
4
8
GAME 14
2
1
1
1
1
8
GAME 15
2
2
4
1
8
GAME 16
2
5
4
8
GAME 17
2
3
4
3...

output:

BBNRKNRQ
BBRKQNNR
BNRQKBRN
BRKRNNQB
QRNBKNBR
BBNRKNRQ
QBRNBKRN
BRKBQNNR
BRQKRNNB
NRKRQNBB
NRQBKNBR
BBNRKNRQ
QBRNBKRN
BRKBQNNR
RKBBRNNQ
BQNBNRKR
NRNBKQBR
BBNRKNRQ
QBRNBKRN
BNRKNQRB
QRNBBNKR
QRNBKRBN
QRNNKBBR
BBNRKNRQ
RKNBBRQN
BNRKQBNR
QBBNRKNR
NQBRNBKR
NRQNKBBR
BBNRKNRQ
QBRNBKRN
BRKBQNNR
BNNQRBKR
NRN...

result:

ok (c) correct after 96 tests, max moves 6 (96 test cases)

Test #9:

score: 0
Accepted
time: 145ms
memory: 3644kb

input:

GAME 1
4
3
0
5
8
GAME 2
3
3
1
2
8
GAME 3
4
4
4
2
8
GAME 4
5
4
5
5
8
GAME 5
4
3
0
8
GAME 6
4
2
1
8
GAME 7
2
1
2
1
8
GAME 8
2
0
2
2
0
8
GAME 9
2
0
1
8
GAME 10
3
1
2
2
8
GAME 11
3
1
3
2
8
GAME 12
2
0
1
6
8
GAME 13
2
4
3
3
8
GAME 14
2
5
2
3
8
GAME 15
3
1
2
3
8
GAME 16
2
6
5
8
GAME 17
3
1
2
1
8
GAME 18
4...

output:

BBNRKNRQ
NRBBKNRQ
BRNKNBRQ
NBQRKNBR
QBBRKNNR
BBNRKNRQ
BBRKQNNR
BRNKRBNQ
BBRNKRQN
NBBRKQNR
BBNRKNRQ
NRBBKNRQ
BRNBKNQR
BQRBKNRN
NBBRKNQR
BBNRKNRQ
BBNRKRQN
BBQRKNNR
BBNRQNKR
QBNRKNBR
BBNRKNRQ
NRBBKNRQ
BRNKNBRQ
NBQRKNBR
BBNRKNRQ
NRBBKNRQ
BBRNNKRQ
NBNRKQBR
BBNRKNRQ
QBRNBKRN
BQNNRBKR
BNRKRNQB
QNBRKBNR
BBN...

result:

ok (c) correct after 96 tests, max moves 6 (96 test cases)

Test #10:

score: 0
Accepted
time: 125ms
memory: 3640kb

input:

GAME 1
2
3
4
1
8
GAME 2
2
4
6
8
GAME 3
2
4
8
GAME 4
1
1
2
0
6
8
GAME 5
1
1
2
0
8
GAME 6
1
2
3
4
8
GAME 7
1
1
1
2
6
8
GAME 8
1
1
1
2
8
GAME 9
1
2
3
8
GAME 10
1
0
2
5
8
GAME 11
1
0
2
3
0
8
GAME 12
1
0
3
2
5
8
GAME 13
0
1
0
8
GAME 14
0
2
6
8
GAME 15
0
2
8
GAME 16
0
1
2
3
8
GAME 17
0
2
5
5
8
GAME 18
0
3...

output:

BBNRKNRQ
QBRNBKRN
BBRKQRNN
RBNKBRQN
BBRQNKNR
BBNRKNRQ
QBRNBKRN
BBRNNKQR
BBRNQKNR
BBNRKNRQ
QBRNBKRN
BBRNNKQR
BBNRKNRQ
RKNBBRQN
BRQKRBNN
NRQNKRBB
BNRBQKNR
BQRBNKNR
BBNRKNRQ
RKNBBRQN
BRQKRBNN
NRQNKRBB
BNRBQKNR
BBNRKNRQ
RKNBBRQN
NRNBQKBR
NBRNBKQR
BNRBNKQR
BBNRKNRQ
RKNBBRQN
BRQKRBNN
BNRBNQKR
NBRQBKNR
QBR...

result:

ok (c) correct after 96 tests, max moves 6 (96 test cases)

Test #11:

score: 0
Accepted
time: 135ms
memory: 3904kb

input:

GAME 1
2
1
4
5
8
GAME 2
1
3
2
2
3
8
GAME 3
1
4
3
2
4
8
GAME 4
1
3
4
6
8
GAME 5
0
4
5
5
8
GAME 6
1
3
5
3
2
8
GAME 7
2
0
5
4
3
8
GAME 8
3
4
5
4
8
GAME 9
2
0
4
2
8
GAME 10
1
0
3
3
8
GAME 11
2
0
3
0
6
8
GAME 12
2
1
6
8
GAME 13
1
1
1
4
6
8
GAME 14
1
1
1
3
4
8
GAME 15
0
5
8
GAME 16
0
6
6
8
GAME 17
0
6
8
G...

output:

BBNRKNRQ
QBRNBKRN
BQNNRBKR
BQRBNNKR
RQNBBNKR
BBNRKNRQ
RKNBBRQN
RKNQNBBR
RQKRBBNN
QRNBBKNR
RNQBBNKR
BBNRKNRQ
RKNBBRQN
RKBBNQRN
RKNQRBBN
RKQBBNNR
RNNBBQKR
BBNRKNRQ
RKNBBRQN
RKNQNBBR
RQNKBBNR
RQNNBBKR
BBNRKNRQ
NRBNQBKR
NNRQBBKR
RNBQNBKR
RNQNBBKR
BBNRKNRQ
RKNBBRQN
RKNQNBBR
RKBQNBRN
RKQBNNBR
RNNQBBKR
BBN...

result:

ok (c) correct after 96 tests, max moves 6 (96 test cases)

Extra Test:

score: 0
Extra Test Passed