QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#263676 | #7179. Fischer's Chess Guessing Game | sofija6 | WA | 6ms | 7512kb | C++23 | 2.4kb | 2023-11-25 02:41:39 | 2023-11-25 02:41:40 |
Judging History
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("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;
}
詳細信息
Test #1:
score: 0
Wrong Answer
time: 6ms
memory: 7512kb
input:
GAME 1
output:
KQRRBBNN
result:
wrong answer (i) illegal position "KQRRBBNN" (game 1, guess 1) (test case 1)