QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#263693#7179. Fischer's Chess Guessing Gamesofija6WA 36ms7360kbC++232.5kb2023-11-25 03:23:432023-11-25 03:23:44

Judging History

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

  • [2023-11-25 03:23:44]
  • 评测
  • 测评结果:WA
  • 用时:36ms
  • 内存:7360kb
  • [2023-11-25 03:23:43]
  • 提交

answer

#include <bits/stdc++.h>
#define ll int
#define MAXN 970
using namespace std;
vector<string> v;
bitset<MAXN> ch;
ll same[MAXN][MAXN],ans;
ll Num_Of_Same(ll i,ll j)
{
    ll cnt=0;
    for (ll l=0;l<8;l++)
        cnt+=v[i][l]==v[j][l];
    return cnt;
}
bool Cmp(ll i,ll j)
{
    return i>j;
}
void Solve(ll a)
{
    for (ll i=0;i<v.size();i++)
    {
        if (same[ans][i]!=a)
            ch[i]=false;
    }
    ll maxx=1e6;
    for (ll i=0;i<v.size();i++)
    {
        if (!ch[i])
            continue;
        ll cnt[10]={0},m=-1;
        for (ll j=0;j<v.size();j++)
        {
            if (!ch[j] && i!=j)
                continue;
            cnt[same[i][j]]++;
            m=max(m,cnt[same[i][j]]);
        }
        if (m<maxx)
        {
            ans=i;
            maxx=m;
        }
    }
}
void Create(string s)
{
    vector<ll> p;
    set<string> ss;
    ss.insert(s);
    for (ll i=0;i<8;i++)
        p.push_back(i);
    while (next_permutation(p.begin(),p.end()))
    {
        string s1="........";
        for (ll i=0;i<8;i++)
            s1[i]=s[p[i]];
        ll r=0,b=-1;
        bool yes=true;
        for (ll i=0;i<8;i++)
        {
            if (s1[i]=='K' && r!=1)
            {
                yes=false;
                break;
            }
            if (s1[i]=='B' && b!=-1 && b==(i%2))
            {
                yes=false;
                break;
            }
            if (s1[i]=='R')
                r++;
            if (s1[i]=='B' && b==-1)
                b=(i%2);
        }
        if (yes && !ss.count(s1))
            v.push_back(s1);
        ss.insert(s1);
    }
}
int main()
{
    string x="";
    ll ans0,a,n,maxx=1e6;
    Create("KQRRBBNN");
    ans0=0;
    for (ll i=0;i<v.size();i++)
    {
        ll cur=0;
        for (ll j=0;j<v.size();j++)
        {
            ll cnt=Num_Of_Same(i,j);
            same[i][j]=cnt;
            cur=max(cur,cnt);
        }
        if (cur<=maxx)
        {
            ans0=i;
            maxx=cur;
        }
    }
    while (true)
    {
        cin >> x;
        if (x=="END")
            return 0;
        cin >> n;
        ans=ans0;
        for (ll i=0;i<v.size();i++)
            ch[i]=1;
        ll cc=0;
        while (true)
        {
            cc++;
            if (cc>6)
                return 0;
            cout << v[ans] << "\n";
            cin >> a;
            if (a==8)
                break;
            Solve(a);
        }
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 12ms
memory: 7356kb

input:

GAME 1
2
2
2
3
3
8
END

output:

NNBBRQKR
RNBQKBRN
RBBKRNNQ
BNRBKRNQ
QNRKBBNR
RKRBBQNN

result:

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

Test #2:

score: 0
Accepted
time: 36ms
memory: 7316kb

input:

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

output:

NNBBRQKR
RNBQKBRN
RBBKRNNQ
BNRBKRNQ
QNRKBBNR
RKRBBQNN
NNBBRQKR
RBNNQKBR
RKQBBNRN
RKQBBRNN
RKRBBNQN
NNBBRQKR
RBNNQKBR
RKQBBNRN
RKRBBNNQ
NNBBRQKR
RBNNQKBR
RNQNBKRB
RKRBQNBN
NNBBRQKR
RNBQKBRN
RBBKRNNQ
QNRKNBBR
RKRBNQBN
NNBBRQKR
RBNNQKBR
RKBNNRQB
RKBRQBNN
RQKBNRBN
RKRBNNBQ
NNBBRQKR
BRQKNNRB
QBRNKRBN
RKR...

result:

ok (c) correct after 96 tests, max moves 6 (96 test cases)

Test #3:

score: 0
Accepted
time: 23ms
memory: 7272kb

input:

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

output:

NNBBRQKR
RNBQKBRN
RQNBBKNR
RKQBBNNR
NNBBRQKR
QRNBBNKR
QBBRNNKR
RKNBBQNR
NNBBRQKR
RNBQKBRN
RQNBBKNR
RKQBBNNR
RKNBBNQR
NNBBRQKR
RNBQKBRN
RQNBBKNR
NRNKBBQR
QBBRNKNR
RKQBNNBR
NNBBRQKR
RNBQKBRN
RQNBBKNR
NBRQBKNR
RKNBQNBR
NNBBRQKR
QRNBBNKR
RBBNQNKR
NQRBKNBR
RKNBNQBR
NNBBRQKR
RBNNQKBR
RNQNBKRB
RKQNRNBB
RKQ...

result:

ok (c) correct after 96 tests, max moves 6 (96 test cases)

Test #4:

score: 0
Accepted
time: 32ms
memory: 7328kb

input:

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

output:

NNBBRQKR
BRQKNNRB
QBNRBKRN
QRKRBBNN
NNBBRQKR
RBNNQKBR
QNRKBNRB
NRKRBBNQ
NRKRBBQN
NNBBRQKR
RBNNQKBR
QNRKBNRB
NRKRBBNQ
NNBBRQKR
BRQKNNRB
BRNNKBRQ
QBRKBNRN
QRKRBNNB
NNBBRQKR
RNBQKBRN
QBRNBNKR
BRQBNKNR
NRKRBQNB
NNBBRQKR
RBNNQKBR
QNRKBNRB
QRBKNRNB
NRKRBNQB
NNBBRQKR
BRQKNNRB
QRKNBBRN
QRKRNBBN
NNBBRQKR
RBN...

result:

ok (c) correct after 96 tests, max moves 6 (96 test cases)

Test #5:

score: -100
Wrong Answer
time: 9ms
memory: 7360kb

input:

GAME 1
1
3
1
3
8
GAME 2
2
4
1
2
8
GAME 3
2
3
5
8
GAME 4
1
3
2
6
8
GAME 5
2
2
4
1
4
8
GAME 6
3
1
3
2
2
8
GAME 7
1
3
1
3
3
3

output:

NNBBRQKR
RBNNQKBR
RNQNBKRB
RKRBQNBN
RQNKRBBN
NNBBRQKR
RNBQKBRN
QRBBKNRN
RKBQNBNR
RNQKRBBN
NNBBRQKR
RNBQKBRN
RNNKBBQR
RNNKRBBQ
NNBBRQKR
RBNNQKBR
RNQNBKRB
RKNQRNBB
RQNKRNBB
NNBBRQKR
RNBQKBRN
RBBKRNNQ
RKBBNRNQ
RBNKRQBN
RNQKRNBB
NNBBRQKR
QRNBBNKR
RNBKQBNR
RNBBKRQN
NNQRKBBR
RNNKRQBB
NNBBRQKR
RBNNQKBR
RNQ...

result:

wrong answer (i) too many guesses in game 7, pos = `#