QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#469772#7179. Fischer's Chess Guessing GamePedro_SimTL 1ms3672kbC++171.6kb2024-07-10 00:47:042024-07-10 00:47:04

Judging History

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

  • [2024-07-10 00:47:04]
  • 评测
  • 测评结果:TL
  • 用时:1ms
  • 内存:3672kb
  • [2024-07-10 00:47:04]
  • 提交

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;
    vector<string> temp = resp;
    for(int i = 0; i < 6; i++){
        string at = temp[0];
        cout << at << endl;
        fflush (stdout);
        int t=0;
        cin >> t;
        //rp(i, 0, 8) if(comp[i] == at[i]) t++;
        if(t == 8) return;
        vector<string> comp;
        for(int j = 1; j < temp.size(); j++){
            int d = 0;
            for(int k = 0; k < 8; k++) if(at[k] == temp[j][k]) d++;
            if(d == t) comp.push_back(temp[j]);
        }
        temp = comp;
    }
}

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

int main(){
    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: 1ms
memory: 3672kb

input:

GAME 1
0
1
2
2
8
END

output:

BBNNQRKR
NNBBRKRQ
NRKRBBQN
RKBRNNQB
RKRBBQNN

result:

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

Test #2:

score: -100
Time Limit Exceeded

input:

GAME 1
0
1
2
2
8
GAME 2
0
1
3
8
GAME 3
0
2
2
1
2
8
GAME 4
1

output:

BBNNQRKR
NNBBRKRQ
NRKRBBQN
RKBRNNQB
RKRBBQNN
BBNNQRKR
NNBBRKRQ
NRKRBBQN
RKRBBNQN
BBNNQRKR
NNBBRKRQ
NQRKBBRN
NRKRNBBQ
QNRKRNBB
RKRBBNNQ
BBNNQRKR
BNBQRKRN

result: