QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#224178#7179. Fischer's Chess Guessing GameMihailo_JancevicCompile Error//C++142.5kb2023-10-23 00:19:402023-10-23 00:19:42

Judging History

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

  • [2023-10-23 00:19:42]
  • 评测
  • [2023-10-23 00:19:40]
  • 提交

answer

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

vector<string> sol0, sol, sol1;
string s;
int dif[1000][10], t, x, mindif, j;

void gen(string s, int r, int b, int n, int k, int q) {
    if(s.size()==8) {
        sol0.push_back(s);
        return;
    }
    if(r==1&&k==0) gen(s+"K", r, b, n, k+1, q);
    if(r==0||(k==1&&r==1)) gen(s+"R", r+1, b, n, k, q);
    if(n<2) gen(s+"N", r, b, n+1, k, q);
    if(b==0) gen(s+"B", r, s.size()+1, n, k, q);
    if(b<10&&b>0&&(b+s.size()+1)%2) gen(s+"B", r, 100, n, k, q);
    if(q==0) gen(s+"Q", r, b, n, k, q+1);
}

int main() {
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    gen("", 0, 0, 0, 0, 0);
    while(true) {
        cin>>s;
        if(s[0]=='E') break;
        cin>>s;
        sol=sol0;
        for(int i=0; i<sol.size(); i++) {
            if(sol[i]=="RQKNBBRN") {
                cout<<sol[i]<<endl;
                cin>>x;
                j=i;
                break;
            }
        }
        if(x==8) goto label;
        sol1.clear();
        for(int i=0; i<sol.size(); i++) {
            t=0;
            for(int k=0; k<8; k++) {
                if(sol[i][k]==sol[j][k]) t++;
            }
            if(t==x) sol1.push_back(sol[i]);
        }
        sol=sol1;
        while(sol.size()>1) {
            mindif=1204374;
            for(int i=0; i<sol.size(); i++) {
                for(int j=0; j<9; j++) dif[i][j]=0;
                for(int j=0; j<sol.size(); j++) {
                    t=0;
                    for(int k=0; k<8; k++) {
                        if(sol[i][k]==sol[j][k]) t++;
                    }
                    dif[i][t]++;
                }
                for(int k=1; k<9; k++) {
                    dif[i][0]=max(dif[i][0], dif[i][k]);
                }
                mindif=min(mindif, dif[i][0]);
            }
            for(int i=0; i<sol.size(); i++) {
                if(dif[i][0]==mindif) {
                    cout<<sol[i]<<endl;
                    cin>>x;
                    j=i;
                    break;
                }
            }
            if(x==8) break;
            sol1.clear();
            for(int i=0; i<sol.size(); i++) {
                t=0;
                for(int k=0; k<8; k++) {
                    if(sol[i][k]==sol[j][k]) t++;
                }
                if(t==x) sol1.push_back(sol[i]);
            }
            sol=sol1;
        }
        if(x!=8) {
            cout<<sol[0]<<endl;
            cin>>x;
        }
        label:
    }
}

Details

answer.code: In function ‘int main()’:
answer.code:87:5: error: expected primary-expression before ‘}’ token
   87 |     }
      |     ^