QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#224257#7179. Fischer's Chess Guessing Gamesofija6WA 210ms77072kbC++172.0kb2023-10-23 00:51:382023-10-23 00:51:39

Judging History

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

  • [2023-10-23 00:51:39]
  • 评测
  • 测评结果:WA
  • 用时:210ms
  • 内存:77072kb
  • [2023-10-23 00:51:38]
  • 提交

answer

#include <bits/stdc++.h>
#define ll long long
using namespace std;
set<string> v;
set<pair<string,ll> > S;
void Create(string s,ll b,ll p,ll k,ll n,ll q,ll r)
{
    if ((ll)s.size()==8)
    {
        v.insert(s);
        return;
    }
    string c=s;
    if (!b || (b==1 && p!=s.size()%2))
    {
        c+='B';
        Create(c,b+1,s.size()%2,k,n,q,r);
        c=s;
    }
    if (!k && r==1)
    {
        c+='K';
        Create(c,b,p,k+1,n,q,r);
        c=s;
    }
    if (n!=2)
    {
        c+='N';
        Create(c,b,p,k,n+1,q,r);
        c=s;
    }
    if (!q)
    {
        c+='Q';
        Create(c,b,p,k,n,q+1,r);
        c=s;
    }
    if (!r || (r==1 && k==1))
    {
        c+='R';
        Create(c,b,p,k,n,q,r+1);
    }
    return;
}
map<string,set<string> > c[10];
set<string> w;
string Get_Min()
{
    ll maxx=LLONG_MAX;
    string ans;
    for (auto i : w)
    {
        ll cur=0;
        for (ll j=0;j<8;j++)
        {
            ll num=0;
            cur=max(cur,(ll)(c[j][i].size()));
        }
        bool check=true;
        for (auto j : S)
        {
            if (!c[j.second][i].count(j.first))
                check=false;
        }
        if (cur<maxx && check)
        {
            maxx=cur;
            ans=i;
        }
    }
    return ans;
}
int main()
{
    string s="";
    Create(s,0,0,0,0,0,0);
    for (auto i : v)
    {
        for (auto j : v)
        {
            ll cnt=0;
            for (ll p=0;p<8;p++)
                cnt+=(i[p]!=j[p]);
            c[cnt][i].insert(j);
        }
    }
    string x;
    ll n,a;
    cin >> x >> n;
    while (n--)
    {
        S.clear();
        w=v;
        s=Get_Min();
        while (true)
        {
            cout << s << "\n";
            cin >> a;
            S.insert({s,8-a});
            if (a==8)
                break;
            w=c[8-a][s];
            s=Get_Min();
        }
    }
    cin >> x;
    return 0;
}

详细

Test #1:

score: 100
Accepted
time: 210ms
memory: 76868kb

input:

GAME 1
1
4
3
1
8
END

output:

NRBBNKQR
RQKBBNRN
RBQNBKRN
RQBNKNRB
RKRBBQNN

result:

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

Test #2:

score: -100
Wrong Answer
time: 202ms
memory: 77072kb

input:

GAME 1
1
4
3
1
8
GAME 2

output:

NRBBNKQR
RQKBBNRN
RBQNBKRN
RQBNKNRB
RKRBBQNN

result:

wrong answer (i) illegal position "" (game 2, guess 1) (test case 2)