QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#641482#7179. Fischer's Chess Guessing GamePedro_SimAC ✓296ms3928kbC++202.5kb2024-10-14 20:43:062024-10-14 20:43:06

Judging History

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

  • [2024-10-14 20:43:06]
  • 评测
  • 测评结果:AC
  • 用时:296ms
  • 内存:3928kb
  • [2024-10-14 20:43:06]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rp(i,a,b)        for(int i=a;i<b;i++)

vector<string> resp;

bool veri(string &t) {
    int te = -1;
    rp(i, 0, 8){
        if(te >= 0 && t[i] == 'B' && (i%2) == (te%2)) return false;
        else if(t[i] == 'B') te = i;
    }
    rp(i, 0, 8){
        if(t[i] == 'K'){
            bool flag1 = true, flag2 = true;
            rp(j, 0, i) if(t[j] == 'R') flag1 = false;
            rp(j, i, 8) if(t[j] == 'R') flag2 = false;
            if(flag1 || flag2) return false;
            break;
        }
    }
    return true;
}

void solvetask() {
    int n;
    cin >> n;
    
    //for(auto original: resp){
        vector<string> currentState = resp; 
        string best;
    for(int turn = 0; turn < 7; turn++) {
        // if(turn == 6) {
        //     cout << original << " " << currentState.size() << "\n";
        //     break;
        // }

        double mx = 1e9;
        string chute;
        for (auto &comp : currentState) {
            vector<int> bins(9, 0); 
                
            for (auto &candidate : currentState) {
                int matches = 0;
                rp(k, 0, 8)  if (comp[k] == candidate[k]) matches++;
                bins[matches]++;
            }

            double melhorbin = 0;
            for(auto i: bins) melhorbin += i*sqrt(i);
            if (melhorbin < mx) {
                mx = melhorbin;
                chute = comp;
            }
        }

        if(turn == 0) chute = "RBBNNQKR";

       // if(turn == 5) chute = currentState[rand()%(currentState.size())];
        

        cout << chute << endl;
        fflush(stdout);
        int iguais=0;
        cin >> iguais;
       // rp(k, 0, 8) if (chute[k] == original[k]) iguais++;
        if (iguais == 8) break;

        vector<string> newState;
        for (auto &comp : currentState) {
            int matches = 0;
            rp(k, 0, 8) if (comp[k] == chute[k]) matches++;
            if (matches == iguais) newState.push_back(comp);
        }
        currentState = newState;
    }
    //}
}

void pre_cal() {
    string temp = "BBQKNNRR";
    sort(temp.begin(), temp.end());
    while(next_permutation(temp.begin(), temp.end())) if(veri(temp)) resp.push_back(temp);
}

int main() {
    srand(time(0));
    cin.tie(0)->sync_with_stdio(0);
    string t;
    pre_cal();

    while (true) {
        cin >> t;
        if (t == "END") return 0; 
        solvetask();
    }
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 4ms
memory: 3688kb

input:

GAME 1
2
3
1
1
2
8
END

output:

RBBNNQKR
RKNBQNBR
NRQBNKBR
RNKNQRBB
BBRKQNNR
RKRBBQNN

result:

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

Test #2:

score: 0
Accepted
time: 271ms
memory: 3796kb

input:

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

output:

RBBNNQKR
RKNBQNBR
NRQBNKBR
RNKNQRBB
BBRKQNNR
RKRBBQNN
RBBNNQKR
RNQBBKRN
RKNQBBRN
NBRQBKRN
RKRBBNQN
RBBNNQKR
RNQBBKRN
RKNBBRNQ
RKRBBNNQ
RBBNNQKR
RNQBBKRN
RKNBBRNQ
NBNRBKRQ
RKRBQNBN
RBBNNQKR
RKBNQBRN
RKBQNRNB
RKRBNQBN
RBBNNQKR
RKNBQNBR
RKNNQRBB
RKBBQNRN
RKRBNNBQ
RBBNNQKR
RNQBBKRN
RKNBBRNQ
RNKRBBNQ
RKN...

result:

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

Test #3:

score: 0
Accepted
time: 258ms
memory: 3844kb

input:

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

output:

RBBNNQKR
RKNBQNBR
RKNNQRBB
RKQBBNNR
RBBNNQKR
RKBNQBRN
NRQNBBKR
BBRNQKNR
BRKNNQRB
RKNBBQNR
RBBNNQKR
RKNBQNBR
RNKBQNBR
RKNBBNQR
RBBNNQKR
RKBNQBRN
NRQNBBKR
BBRNQKNR
RNKQNBBR
RKQBNNBR
RBBNNQKR
RKNBQNBR
RBBNNQKR
BBRNQNKR
RQBBNKNR
RBBQNKRN
RKNBNQBR
RBBNNQKR
RKBNQBRN
RKBQNNRB
RBBKQRNN
RKQNBBNR
RBBNNQKR
RKN...

result:

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

Test #4:

score: 0
Accepted
time: 272ms
memory: 3776kb

input:

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

output:

RBBNNQKR
BNRBKRQN
NRKQRBBN
BRKQRNNB
QRKRBBNN
RBBNNQKR
BNRBKRQN
NNRQBKRB
BQNRKNRB
NQRKRBBN
NRKRBBQN
RBBNNQKR
BNRBKRQN
QRNKRNBB
NRKRBBNQ
RBBNNQKR
BNRBKRQN
QRNKRNBB
NRKRQNBB
QRKRBNNB
RBBNNQKR
RNQBBKRN
BNRNKRQB
NRBKRBQN
NRKBNRBQ
NRKRBQNB
RBBNNQKR
BNRBKRQN
NRKQRBBN
BRNKRBNQ
NRKRBNQB
RBBNNQKR
RNQBBKRN
BNR...

result:

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

Test #5:

score: 0
Accepted
time: 268ms
memory: 3712kb

input:

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

output:

RBBNNQKR
RNQBBKRN
BRKBNNRQ
RKNQBRNB
NBRKBRQN
RQNKRBBN
RBBNNQKR
RNQBBKRN
RKNQBBRN
NRKBBQRN
RNQKRBBN
RBBNNQKR
RNQBBKRN
BRKBNNRQ
BBQRKRNN
NQNBRKBR
RNNKRBBQ
RBBNNQKR
RNQBBKRN
BNRNKRQB
NRBKRBQN
NRKBNRBQ
RQNKRNBB
RBBNNQKR
RNQBBKRN
RKNBBRNQ
RNQKRNBB
RBBNNQKR
RKNBQNBR
NRQBNKBR
RNKNQRBB
RNNKRQBB
RBBNNQKR
RKB...

result:

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

Test #6:

score: 0
Accepted
time: 272ms
memory: 3768kb

input:

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

output:

RBBNNQKR
RKNBQNBR
BBRKNRQN
QRBKNRNB
QRBKNBRN
RBBNNQKR
RNQBBKRN
BRKBNNRQ
NRBQKBRN
NRBKQBRN
RBBNNQKR
RKNBQNBR
BBRKNRQN
BRKNNBRQ
BRQNNKRB
NRBKNBRQ
RBBNNQKR
RKNBQNBR
NRBQKBNR
BRNNKQRB
NRKRNQBB
QRBKNNRB
RBBNNQKR
RNQBBKRN
BNRNKRQB
NRBKRBQN
NRBKQNRB
RBBNNQKR
RKBNQBRN
NRQNBBKR
BBRNQKNR
NRBKNQRB
RBBNNQKR
BNR...

result:

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

Test #7:

score: 0
Accepted
time: 265ms
memory: 3856kb

input:

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

output:

RBBNNQKR
RKBNQBRN
RKBQNRNB
RBBQKRNN
RBBNNQKR
BBRNQNKR
QNBRNBKR
RBBNKRNQ
RBBNKRQN
RBBNNQKR
BBRNQNKR
QNBRNBKR
RBBNKRNQ
RBBNNQKR
RKBNQBRN
RKBQNRNB
RBKNBRQN
RBQNKRBN
RBBNNQKR
RKNBQNBR
NRQBNKBR
RNKNQRBB
RBKQRNBN
RBNQKRBN
RBBNNQKR
RKBNQBRN
NRQNBBKR
BBRNNKRQ
RBKNRNBQ
RBNNKRBQ
RBBNNQKR
RKNBQNBR
RBQKBNRN
RNB...

result:

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

Test #8:

score: 0
Accepted
time: 296ms
memory: 3684kb

input:

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

output:

RBBNNQKR
RNQBBKRN
BNRNKRQB
NRBKRBQN
BRKBQNNR
QRNBKNBR
RBBNNQKR
RNQBBKRN
BRKBNNRQ
BQRKNBRN
NRQBKNBR
RBBNNQKR
RKNBQNBR
RKNQNRBB
NBNRQKBR
NRNBKQBR
RBBNNQKR
RKNBQNBR
NRQBNKBR
BRNBKQNR
QRNNKBBR
RBBNNQKR
RKNBQNBR
RBQKBNRN
NRNQBBKR
BRNKNBQR
NRQNKBBR
RBBNNQKR
RNQBBKRN
BRKNRNQB
BBNRKRNQ
NRNQKBBR
RBBNNQKR
RNQ...

result:

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

Test #9:

score: 0
Accepted
time: 260ms
memory: 3928kb

input:

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

output:

RBBNNQKR
RKBNQBRN
BBNNRKQR
QNBBRNKR
QBBRKNNR
RBBNNQKR
BBRNQNKR
QNBRNBKR
RQKNNBBR
NBBRKQNR
RBBNNQKR
RKBNQBRN
BBNNRKQR
RBNQKNBR
NBBRKNQR
RBBNNQKR
RKNBQNBR
RKNQNRBB
NBNRQKBR
QBNRKNBR
RBBNNQKR
RKNBQNBR
NRQBNKBR
BRKBNNQR
NBQRKNBR
RBBNNQKR
RKBNQBRN
NNRBBQKR
BQNBNRKR
NBNRKQBR
RBBNNQKR
RKNBQNBR
NRBQKBNR
BRK...

result:

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

Test #10:

score: 0
Accepted
time: 284ms
memory: 3852kb

input:

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

output:

RBBNNQKR
RKBNQBRN
NNRBBQKR
BBRKNNQR
BBRQNKNR
RBBNNQKR
RKBNQBRN
NRQNBBKR
BBRNQKNR
RBBNNQKR
BBRNQNKR
BBRNKQNR
BBRNNKQR
RBBNNQKR
RKNBQNBR
RBQKBNRN
BRNNKBQR
BQRBNKNR
RBBNNQKR
RNQBBKRN
RKNBBRNQ
QNNBRKBR
BNRBQKNR
RBBNNQKR
RKNBQNBR
RBQKBNRN
BRNNKBQR
BNRBKQNR
BNRBNKQR
RBBNNQKR
RKBNQBRN
BBNNRKQR
QBRNBKNR
RBB...

result:

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

Test #11:

score: 0
Accepted
time: 277ms
memory: 3848kb

input:

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

output:

RBBNNQKR
RKBNQBRN
BBNNRKQR
QNBBRNKR
QBBRKNNR
RQNBBNKR
RBBNNQKR
RKBNQBRN
BBNNRKQR
NRBBKQNR
RNQBBNKR
RBBNNQKR
BBRNQNKR
QNBRNBKR
RQKNNBBR
RNNBBQKR
RBBNNQKR
BBRNQNKR
RBQNBKNR
NBBNRKQR
RBQKNNBR
RQNNBBKR
RBBNNQKR
BBRNQNKR
RBQNBKNR
QBBNRKNR
RNQNBBKR
RBBNNQKR
RKBNQBRN
NRQNBBKR
BRKNNBQR
NNBQRBKR
RNNQBBKR
RBB...

result:

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

Extra Test:

score: 0
Extra Test Passed