QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#263691#7179. Fischer's Chess Guessing Gamesofija6WA 36ms7348kbC++232.8kb2023-11-25 03:21:122023-11-25 03:21:12

Judging History

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

  • [2023-11-25 03:21:12]
  • 评测
  • 测评结果:WA
  • 用时:36ms
  • 内存:7348kb
  • [2023-11-25 03:21:12]
  • 提交

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,cntmax[10];
    for (ll i=0;i<9;i++)
        cntmax[i]=1e6;
    Create("KQRRBBNN");
    ans0=0;
    for (ll i=0;i<v.size();i++)
    {
        ll cntt[10]={0};
        for (ll j=0;j<v.size();j++)
        {
            ll cnt=Num_Of_Same(i,j);
            same[i][j]=cnt;
            cntt[cnt]++;
        }
        sort(cntt,cntt+8);
        for (ll j=0;j<9;j++)
        {
            if (cntmax[j]<cntt[j])
                break;
            if (cntmax[j]>cntt[j])
            {
                ans0=i;
                for (ll l=0;l<9;l++)
                    cntmax[l]=cntt[l];
                break;
            }
        }
    }
    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: 11ms
memory: 7272kb

input:

GAME 1
1
2
2
4
8
END

output:

QNNRBKRB
NRNBKQBR
RNKBRNBQ
RBKNBQNR
RKRBBQNN

result:

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

Test #2:

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

input:

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

output:

QNNRBKRB
NRNBKQBR
RNKBRNBQ
RBKNBQNR
RKRBBQNN
QNNRBKRB
NRNBKQBR
BRQKNRNB
RKRBBNQN
QNNRBKRB
NRNBKQBR
BRQKNRNB
QBRKRNBN
RBKQBNNR
RKRBBNNQ
QNNRBKRB
NRKBQRBN
RKQBNRBN
RKRBQNBN
QNNRBKRB
NRKBQRBN
RQKNRBBN
RKRBNQBN
QNNRBKRB
NRKBQRBN
BRKQNBNR
BBRNKRQN
RKRBNNBQ
QNNRBKRB
NRNBKQBR
RKRNBBQN
RKRQBBNN
QNNRBKRB
NRN...

result:

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

Test #3:

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

input:

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

output:

QNNRBKRB
NRNBKQBR
RNKBRNBQ
QRKNRBBN
RKQBBNNR
QNNRBKRB
RQKNBBRN
RQNKNRBB
NRKQBRNB
RKNBBQNR
QNNRBKRB
RQKNBBRN
RQNKNRBB
NRKQBRNB
QRNNKBBR
RKNBBNQR
QNNRBKRB
NRKBQRBN
BRKQNBNR
RKQBNNBR
QNNRBKRB
NRNBKQBR
RBNKNQBR
RKNBQNBR
QNNRBKRB
NRNBKQBR
RKNBNQBR
QNNRBKRB
NRNBKQBR
BRQKNRNB
BBRNNKQR
RKQNBBNR
QNNRBKRB
RQK...

result:

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

Test #4:

score: -100
Wrong Answer
time: 20ms
memory: 7332kb

input:

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

output:

QNNRBKRB
QRNKBBNR
RNNKBBQR
QRKRBBNN
QNNRBKRB
RQKNBBRN
QRBNKBRN
RQBBNKRN
NRKRBBQN
QNNRBKRB
RQKNBBRN
RKQNBRNB
BQRNKNRB
RKNRQBBN
NRKRBBNQ
QNNRBKRB
RNKNBQRB
RQNBBKRN
QRKRBNNB
QNNRBKRB
QRNKBBNR
NNQRBBKR
RNQKBRNB
NRKRBQNB
QNNRBKRB
QRNKBBNR
RQKRBNNB
RNKQBRNB
NRKRBNQB
QNNRBKRB
RQKNBBRN
RKQNBRNB
BRNKQBRN
QRK...

result:

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