QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#250273 | #7179. Fischer's Chess Guessing Game | kilo_tobo_tarjen# | WA | 143ms | 91640kb | C++20 | 2.4kb | 2023-11-13 00:51:33 | 2023-11-13 00:51:33 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
const int maxn=1e6+10;
vector<int>ve[maxn];
int dep[maxn];
string s[maxn],q[maxn];
vector<string> all;
void getlegal()
{
vector<int> a(8);iota(a.begin(),a.end(),0);
string s="RQKBBNRN";
sort(s.begin(),s.end());
do{
string ss;
for(int i=0;i<8;i++)ss.push_back(s[a[i]]);
bool flag=true;
int g=0,k;
vector<int> v;
for(int i=0;i<8;i++){
if(ss[i]=='K')k=i;
if(ss[i]=='R')v.push_back(i);
if(ss[i]=='B')g+=i;
}
if(g%2==1&&k>v[0]&&k<v[1])all.push_back(ss);
}while(next_permutation(a.begin(),a.end()));
sort(all.begin(),all.end());
all.resize(unique(all.begin(),all.end())-all.begin());
}
int f(string s1,string s2){
int res=0;
for(int i=0;i<8;i++)res+=s1[i]==s2[i];
return res;
}
int tot=0;
int dfs(vector<string>&now,int d){
if((int)now.size()==1){
s[++tot]=now[0];
return tot;
}
if(now.empty())return -1;
assert(d<=5);
int id=++tot;
int mi=1e9;
string tt;
for(auto &it:all){
vector<string> p[9];
int g=0;
for(auto &t:now){
int z=f(it,t);
p[z].push_back(t);
g=max((int)p[z].size(),g);
}
if(g<mi){
mi=g;tt=it;
}
}
vector<string> p[9];
for(auto &t:now){
int z=f(tt,t);
p[z].push_back(t);
}
q[id]=tt;
for(int i=0;i<9;i++)ve[id].push_back(dfs(p[i],d+1));
// cout<<"id="<<id<<"\n";
// for(auto it:ve[id])cout<<it<<" ";;cout<<"\n";
return id;
}
void init()
{
getlegal();
dfs(all,1);
}
struct gettime{
clock_t star,ends;
void begin(){
star = clock();
}
void end(){
ends = clock();
cout <<"Running Time : "<<(double)(ends - star)/ CLOCKS_PER_SEC << endl;
}
} tim;
int query(string s){
cout<<s<<endl;
int x;cin>>x;return x;
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
tim.begin();
init();
string z;
while(cin>>z){
if(z=="END")break;
int t;cin>>t;
int now=1;
while(s[now].empty()){
// cout<<"now="<<now<<"\n";
int g=query(q[now]);
now=ve[now][g];
assert(now!=-1);
}
query(s[now]);
}
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 143ms
memory: 91636kb
input:
GAME 1 1 0 2 4 8 END
output:
NRBBNKQR BRNNKBQR NBRKNQBR QBRKBRNN RKRBBQNN
result:
ok (c) correct after 1 tests, max moves 5 (1 test case)
Test #2:
score: -100
Wrong Answer
time: 138ms
memory: 91640kb
input:
GAME 1 1 0 2 4 8 GAME 2 2 3 3 1 1 8 GAME 3 1 0 1 2 8 GAME 4 1 0 2 2 1 8 GAME 5 2 3 4 2 8 GAME 6 2 2 4 0 0 8 GAME 7 0 2 3 2 0 8 GAME 8 1 3 3 0 8 GAME 9 0 3 3 0 8 GAME 10 0 3 3 1 8 GAME 11 0 5 1 0 8 GAME 12 1 2 2 1 0 8 GAME 13 1 1 5 1 8 GAME 14 0 4 4 3 8 GAME 15 1 2 1 2 1 8 GAME 16 1 0 3 1 0 8 GAME 17...
output:
NRBBNKQR BRNNKBQR NBRKNQBR QBRKBRNN RKRBBQNN NRBBNKQR RNBBQKRN RQKBNNBR BBRNNQKR BBNNRKQR RKRBBNQN NRBBNKQR BRNNKBQR NBRKNQBR BNRKQRNB RKRBBNNQ NRBBNKQR BRNNKBQR NBRKNQBR QBRKBRNN BBNNQRKR RKRBQNBN NRBBNKQR RNBBQKRN RQKBNNBR QNRBBKNR RKRBNQBN NRBBNKQR RNBBQKRN QNRBKNBR BBNNQRKR BBNNRKQR RKRBNNBQ NRB...
result:
wrong answer (i) illegal position "" (game 55, guess 2) (test case 55)