QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#226528#7179. Fischer's Chess Guessing GameacagubicaWA 1ms3528kbC++141.7kb2023-10-26 02:37:552023-10-26 02:37:56

Judging History

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

  • [2023-10-26 02:37:56]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3528kb
  • [2023-10-26 02:37:55]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
string secret="BNNRQKRB";
vector<string>all,all2,all3;
string temp;
string s="KNQBRb";
int dozvoli[256],n,brpitanja;
bool uspeh;
void rek(int dubina){
  if(dubina==8){
    all.push_back(temp);
    return;
  }
  for(int i=0; i<s.size(); i++){
    char c=s[i];
    if(dozvoli[c]!=0){
      if(c=='K' and dozvoli['R']!=1)continue;
      if(c=='B' and temp.size()%2==0)continue;
      if(c=='b' and temp.size()%2==1)continue;
      dozvoli[c]--;
      temp.push_back(c);
      rek(dubina+1);
      temp.pop_back();
      dozvoli[c]++;
    }
  }
}
void priprema(){
  dozvoli['R']=2;
  dozvoli['N']=2;
  dozvoli['B']=1;
  dozvoli['b']=1;
  dozvoli['Q']=1;
  dozvoli['K']=1;
  rek(0);
  for(int i=0; i<all.size(); i++)
    for(int j=0; j<all[i].size(); j++)
      if(all[i][j]=='b')all[i][j]='B';
}
int brpoklapanja(string a,string b){
  int ret=0;
  for(int i=0; i<a.size(); i++)ret+=(a[i]==b[i]);
  return ret;
}
int pitaj(string temp){
  brpitanja++;
  cout<<temp<<"\n";
  int ret;
  //ret=brpoklapanja(temp,secret);
  cin>>ret;
  return ret;
}
void prodjisatemp(string temp){
  int poklapanje=pitaj(temp);
  for(int i=0; i<all2.size(); i++)
    if(brpoklapanja(all2[i],temp)!=poklapanje)
      all2[i].clear();
  for(int i=0; i<all2.size(); i++)
    if(all2[i].size()>0)
      all3.push_back(all2[i]);
  all2=all3;
  all3.clear();
  if(poklapanje==8)uspeh=true;
}
int main(){
  priprema();
  string word;
  while(cin>>word){
    if(word=="END")break;
    else cin>>n;
    brpitanja=0;
    uspeh=false;
    for(int i=0; i<all.size(); i++)all2.push_back(all[i]);
    while(!uspeh)prodjisatemp(all2[0]);
  }
  return 0;
}
/*
7 BNNRQKRB
7 BBNRKNRQ
*/

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 3528kb

input:

GAME 1
1
2
2
2
1
4

output:

NNQBRKBR
NQRKBNRB
NBBRKQRN
NRKRBBNQ
QBNRBNKR
RKQNBBRN
RKRBBQNN

result:

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