QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#260395#7179. Fischer's Chess Guessing Gamesofija6WA 18ms7432kbC++232.4kb2023-11-22 07:21:432023-11-22 07:21:45

Judging History

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

  • [2023-11-22 07:21:45]
  • 评测
  • 测评结果:WA
  • 用时:18ms
  • 内存:7432kb
  • [2023-11-22 07:21: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)
{
    v.push_back(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("NRBBNKQR");
    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;
}

详细

Test #1:

score: 100
Accepted
time: 5ms
memory: 7428kb

input:

GAME 1
1
2
2
8
END

output:

NRBBNKQR
BNRKQBNR
RNBQKRNB
RKRBBQNN

result:

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

Test #2:

score: -100
Wrong Answer
time: 18ms
memory: 7432kb

input:

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

output:

NRBBNKQR
BNRKQBNR
RNBQKRNB
RKRBBQNN
NRBBNKQR
RNBNQBKR
QNRBBKRN
NBRNBKRQ
RKRBBNQN
NRBBNKQR
BNRKQBNR
RNBQKRNB
RKRBBQNN
RKRBBNNQ
NRBBNKQR
BNRKQBNR
RNBQKRNB
NQRKRNBB
BQRBKNRN
RKRBQNBN
NRBBNKQR
RNBNQBKR
QNRBBKRN
NNRKBRQB
RKRBNQBN
NRBBNKQR
RNBNQBKR
QNRBBKRN
RKQBNRBN
RKRBNNBQ
NRBBNKQR
RKNNRQBB
RNKNBBRQ
RNQ...

result:

wrong answer (i) too many guesses in game 31, pos = (test case 31)