QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#225739#7179. Fischer's Chess Guessing GameacagubicaWA 4ms3660kbC++142.1kb2023-10-25 02:54:502023-10-25 02:54:51

Judging History

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

  • [2023-10-25 02:54:51]
  • 评测
  • 测评结果:WA
  • 用时:4ms
  • 内存:3660kb
  • [2023-10-25 02:54:50]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
string secret="RNKQNBBR";
vector<string>all,all2,all3;
string temp,s="RNBbQK";
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;
  temp.clear();
  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=1; 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;
    all2=all;
    string temp1,temp2,temp3;
    temp1=all[0];
    for(int i=0; i<all.size(); i++){
      if(brpoklapanja(all[i],temp1)!=0)continue;
      temp2=all[i];
    }
    for(int i=0; i<all.size(); i++){
      if(brpoklapanja(all[i],temp1)!=0)continue;
      if(brpoklapanja(all[i],temp2)!=0)continue;
      temp3=all[i];
    }
    prodjisatemp(temp1);
    if(uspeh)break;
    prodjisatemp(temp2);
    if(uspeh)break;
    prodjisatemp(temp3);
    while(!uspeh)prodjisatemp(all2[0]);
  }
  return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 1ms
memory: 3660kb

input:

GAME 1
4
1
2
2
8
END

output:

RNNBBQKR
QBBNRKRN
BQRKNRNB
RBNKNQBR
RKRBBQNN

result:

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

Test #2:

score: -100
Wrong Answer
time: 4ms
memory: 3632kb

input:

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

output:

RNNBBQKR
QBBNRKRN
BQRKNRNB
RBNKNQBR
RKRBBQNN
RNNBBQKR
QBBNRKRN
BQRKNRNB
RNBQKBNR
RKRBBNQN
RNNBBQKR
QBBNRKRN
BQRKNRNB
RNQKNBBR
RKRBBNNQ
RNNBBQKR
QBBNRKRN
BQRKNRNB
RNKQRNBB
RBKRBNNQ
RKRBQNBN
RNNBBQKR
QBBNRKRN
BQRKNRNB
RNBBKRNQ
RNQKBNRB
RKRBNQBN
RNNBBQKR
QBBNRKRN
BQRKNRNB
RKRBNNBQ
RNNBBQKR
QBBNRKRN
BQR...

result:

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