QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#641439#7179. Fischer's Chess Guessing GamePedro_SimCompile Error//C++202.3kb2024-10-14 20:31:022024-10-14 20:31:02

Judging History

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

  • [2024-10-14 20:31:02]
  • 评测
  • [2024-10-14 20:31:02]
  • 提交

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> currentState = resp; 
    string best;
    for(int turn = 0; turn < 6; turn++) {
        int 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]++;
            }
                
            int melhorbin = *max_element(bins.begin(), bins.end());
            if (melhorbin < mx) {
                mx = melhorbin;
                chute = comp;
            }
        }

        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

answer.code: In function ‘int main()’:
answer.code:86:6: error: expected ‘}’ at end of input
   86 |     }
      |      ^
answer.code:76:12: note: to match this ‘{’
   76 | int main() {
      |            ^