QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#263677#7179. Fischer's Chess Guessing Gamesofija6WA 36ms7760kbC++232.4kb2023-11-25 02:42:152023-11-25 02:42:16

Judging History

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

  • [2023-11-25 02:42:16]
  • 评测
  • 测评结果:WA
  • 用时:36ms
  • 内存:7760kb
  • [2023-11-25 02:42:15]
  • 提交

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;
    Create("KQRRBBNN");
    ans0=0;
    for (ll i=0;i<v.size();i++)
    {
        for (ll j=0;j<v.size();j++)
        {
            ll cnt=Num_Of_Same(i,j);
            same[i][j]=cnt;
        }
    }
    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: 10ms
memory: 7412kb

input:

GAME 1
3
4
4
4
8
END

output:

QRKRBBNN
RKNQBBNR
RKQRBNNB
RKQNBBRN
RKRBBQNN

result:

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

Test #2:

score: 0
Accepted
time: 33ms
memory: 7468kb

input:

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

output:

QRKRBBNN
RKNQBBNR
RKQRBNNB
RKQNBBRN
RKRBBQNN
QRKRBBNN
RNNQBBKR
RKRNQBBN
RKRNBQNB
RKRBBNQN
QRKRBBNN
RNNQBBKR
RKRNQBBN
RKQBBNRN
RKRBBNNQ
QRKRBBNN
RKBBQNNR
RKRBQNBN
QRKRBBNN
RKBBQNNR
BNRBKQNR
RNBBKRQN
RKRBNQBN
QRKRBBNN
RNBNKQRB
BNNBQRKR
RKRBNNBQ
QRKRBBNN
RNKRBQNB
QRKNBNRB
RKRQBBNN
QRKRBBNN
RKNQBBNR
RKQ...

result:

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

Test #3:

score: 0
Accepted
time: 27ms
memory: 7532kb

input:

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

output:

QRKRBBNN
RNNQBBKR
QNRNKBBR
RKRQBNNB
RKQBBNNR
QRKRBBNN
RNNQBBKR
QNRBBNKR
RKNBBQNR
QRKRBBNN
RKBBQNNR
RKRBQNBN
RKNBBNQR
QRKRBBNN
RNBNKQRB
BNNBQRKR
RKNBRNBQ
RKQBNNBR
QRKRBBNN
RNBNKQRB
BNNBQRKR
RKNBQNBR
QRKRBBNN
RNBNKQRB
RQNBKNBR
RKNBNQBR
QRKRBBNN
RKNQBBNR
RKQNBBNR
QRKRBBNN
RKNQBBNR
QRKRBBNN
RNNQBBKR
QNN...

result:

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

Test #4:

score: 0
Accepted
time: 27ms
memory: 7760kb

input:

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

output:

QRKRBBNN
QRKRBBNN
QRKNBBRN
QRKRNBBN
NRKRBBQN
QRKRBBNN
QRKNBBRN
QRKRBNNB
NRKRBBNQ
QRKRBBNN
QRKNBBRN
QRKRBNNB
QRKRBBNN
QRKNRBBN
NRKRBQNB
QRKRBBNN
RNKRBQNB
RBKQBRNN
BRKRQNNB
NRKRBNQB
QRKRBBNN
QRKNBBRN
QRKRNBBN
QRKRBBNN
QRKNRBBN
QRBKRBNN
NRKRQBBN
QRKRBBNN
RNKRBQNB
NRKNBBQR
BRKQNBNR
NRKRNBBQ
QRKRBBNN
RNK...

result:

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

Test #5:

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

input:

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

output:

QRKRBBNN
RNNQBBKR
QNRNKBBR
RKNRNBBQ
RQNKRBBN
QRKRBBNN
RNNQBBKR
QNRNKBBR
NNRKBBRQ
RNQKRBBN
QRKRBBNN
RKBBQNNR
RBNNBKRQ
QBRNNKBR
BQNBRKRN
RNNKRBBQ
QRKRBBNN
RNBNKQRB
RQNBKNBR
RKNBNQBR
RQNKRNBB
QRKRBBNN
RNBNKQRB
RKQNNRBB
RBQNKNBR
RNQKRNBB
QRKRBBNN
RNBNKQRB
BNRNKRQB
RKNNRQBB
RNNKRQBB
QRKRBBNN
RNNQBBKR
BBR...

result:

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

Test #6:

score: 0
Accepted
time: 34ms
memory: 7692kb

input:

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

output:

QRKRBBNN
RNKRBQNB
QRBKNBRN
QRKRBBNN
RKNQBBNR
BRKBNRNQ
QBNRKRBN
NRBKQBRN
QRKRBBNN
RNNQBBKR
BBRQKRNN
QNBRNKRB
NRQNBKRB
NRBKNBRQ
QRKRBBNN
RNNQBBKR
BQRBKRNN
QRBKNNRB
QRKRBBNN
RKBBQNNR
BNRBKQNR
RKQRNNBB
RBBKRNQN
NRBKQNRB
QRKRBBNN
RKBBQNNR
RBNNBKRQ
BNRNKBQR
NRBKNQRB
QRKRBBNN
QRKNRBBN
QRKBBNRN
QRNKBBRN
QRK...

result:

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

Test #7:

score: -100
Wrong Answer
time: 17ms
memory: 7756kb

input:

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

output:

QRKRBBNN
RNNQBBKR
RKRNQBBN
RQKNBNRB
RBBQKRNN
QRKRBBNN
RKBBQNNR
NBBRNKQR
RBKNNQBR
QNRBNKBR
RBBNKRQN
QRKRBBNN
RKBBQNNR
BNRBKQNR
RBBNKRNQ
QRKRBBNN
RKBBQNNR
RBNNBKRQ
QBRNNKBR
BBRNKRNQ
RBQNKRBN
QRKRBBNN
RKBBQNNR
RBNNBKRQ
QBRNNKBR
RBNKRQBN
RBNQKRBN
QRKRBBNN
RNBNKQRB
RKQNNRBB
RBQNKNBR
RBNNKRBQ
QRKRBBNN
RNN...

result:

wrong answer (i) too many guesses in game 50, pos =