QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#226468#7179. Fischer's Chess Guessing Gamesofija6TL 9ms3572kbC++172.4kb2023-10-25 23:27:222023-10-25 23:27:23

Judging History

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

  • [2023-10-25 23:27:23]
  • 评测
  • 测评结果:TL
  • 用时:9ms
  • 内存:3572kb
  • [2023-10-25 23:27:22]
  • 提交

answer

#include <bits/stdc++.h>
#define ll int
using namespace std;
vector<string> v;
vector<pair<string,ll> > S;
vector<string> cor,cor1;
ll cnt[10]={0},cur=0,diff,maxx;
string ans;
void Get_Min()
{
    maxx=INT_MAX;
    for (auto i : cor)
    {
        bool yes=true;
        for (auto j : S)
        {
            ll num=0;
            for (ll p=0;p<8;p++)
                num+=(i[p]!=j.first[p]);
            if (num!=j.second)
                yes=false;
        }
        if (yes)
            cor1.push_back(i);
    }
    cor=cor1;
    cor1.clear();
    for (auto i : cor)
    {
        for (ll j=0;j<10;j++)
            cnt[j]=0;
        cur=0;
        for (auto l : cor)
        {
            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;
}
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;
    cor=v;
    Get_Min();
    string xx=ans;
    while (true)
    {
        if (x=="")
            cin >> x;
        cin >> n;
        S.clear();
        cor=v;
        ans=xx;
        while (true)
        {
            cout << ans << "\n";
            fflush(stdout);
            cin >> a;
            a=8-a;
            if (!a)
            {
                cin >> x;
                if (x=="END")
                    return 0;
                break;
            }
            S.push_back({ans,a});
            Get_Min();
        }
    }
    return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 9ms
memory: 3572kb

input:

GAME 1
1
2
2
1
2
8
END

output:

NRBBNKQR
BNRKQBNR
RNBQKRNB
BRNQKBRN
QNRNBKRB
RKRBBQNN

result:

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

Test #2:

score: -100
Time Limit Exceeded

input:

GAME 1
1
2
2
1
2
8
GAME 2
2
1
0
1
2
8
GAME 3
1
2
2
0
3
8
GAME 4
1
2
1
1
3
8
GAME 5
2
2
0
3
0
8
GAME 6
2
1
2
1
3
8
GAME 7
0
2
3
4
3
8
GAME 8
1
2
1
0
3
8
GAME 9
0
3
1
2
8
GAME 10
0
3
3
3
8
GAME 11
0
5
3
2
8
GAME 12
1
1
1
4
8
GAME 13
1
2
2
3
4
8
GAME 14
0
4
3
4
8
GAME 15
1
2
1
0
1
8
GAME 16
1
1
3
2
2
8...

output:

NRBBNKQR
BNRKQBNR
RNBQKRNB
BRNQKBRN
QNRNBKRB
RKRBBQNN
NRBBNKQR
RBBNKQNR
QRKNNRBB
NBNRBKRQ
BQNBRNKR
RKRBBNQN
NRBBNKQR
BNRKQBNR
RNBQKRNB
BRNQKBRN
RBKNBQNR
RKRBBNNQ
NRBBNKQR
BNRKQBNR
RNBQKRNB
BBNQRNKR
QBRKNRBN
RKRBQNBN
NRBBNKQR
RBBNKQNR
NBNQBRKR
BRKBRQNN
QRBKRNNB
RKRBNQBN
NRBBNKQR
RBBNKQNR
QRKNNRBB
NRK...

result: