QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#225693#7179. Fischer's Chess Guessing Gamesofija6ML 0ms0kbC++172.5kb2023-10-24 23:36:302023-10-24 23:36:31

Judging History

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

  • [2023-10-24 23:36:31]
  • 评测
  • 测评结果:ML
  • 用时:0ms
  • 内存:0kb
  • [2023-10-24 23:36:30]
  • 提交

answer

#include <bits/stdc++.h>
#define ll int
using namespace std;
vector<string> v;
vector<pair<string,ll> > S;
set<string> cor;
string Get_Min()
{
    ll maxx=INT_MAX;
    string ans;
    set<string> ss;
    cout << cor.count("RKRBBQNN") << "\n";
    for (auto j : cor)
    {
        for (auto i : S)
        {
            ll d=0;
            for (ll p=0;p<8;p++)
                d+=(i.first[p]!=j[p]);
            if (d!=i.second)
            {
                ss.insert(j);
                break;
            }
        }
    }
    for (auto i : ss)
        cor.erase(i);
    ll cnt[10]={0},cur=0,diff;
    for (auto i : cor)
    {
        for (ll j=0;j<9;j++)
            cnt[j]=0;
        cur=0;
        for (auto l : cor)
        {
            if (i==l)
                continue;
            diff=0;
            for (ll p=0;p<8;p++)
                diff+=(i[p]!=l[p]);
            cnt[diff]++;
            cur=max(cur,cnt[diff]);
        }
        if (cur<maxx)
        {
            ans=i;
            maxx=cur;
        }
    }
    return ans;
}
ll b,p,k,n,q,r,prevv;
string s;
void Create()
{
    if ((ll)s.size()==8)
    {
        v.push_back(s);
        return;
    }
    if (!b || (b==1 && p!=s.size()%2))
    {
        b++;
        prevv=p;
        p=s.size()%2;
        s+='B';
        Create();
        p=prevv;
        b--;
        s.pop_back();
    }
    if (!k && r==1)
    {
        s+='K';
        k++;
        Create();
        k--;
        s.pop_back();
    }
    if (n!=2)
    {
        s+='N';
        n++;
        Create();
        n--;
        s.pop_back();
    }
    if (!q)
    {
        s+='Q';
        q++;
        Create();
        q--;
        s.pop_back();
    }
    if (!r || (r==1 && k==1))
    {
        s+='R';
        r++;
        Create();
        r--;
        s.pop_back();
    }
    return;
}
int main()
{
    string x="";
    Create();
    ll a;
    while (true)
    {
        if (x=="")
            cin >> x;
        cin >> n;
        S.clear();
        for (auto i : v)
            cor.insert(i);
        s=Get_Min();
        while (true)
        {
            cout << s << "\n";
            cin >> a;
            a=8-a;
            if (!a)
            {
                cin >> x;
                if (x=="END")
                    return 0;
                break;
            }
            S.push_back({s,a});
            s=Get_Min();
        }
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Memory Limit Exceeded

input:

GAME 1

output:

1
NRBBNKQR

result: