QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#224014#7179. Fischer's Chess Guessing GameNemanjaSo2005AC ✓1279ms3976kbC++142.3kb2023-10-22 22:59:452023-10-22 22:59:45

Judging History

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

  • [2023-10-22 22:59:45]
  • 评测
  • 测评结果:AC
  • 用时:1279ms
  • 内存:3976kb
  • [2023-10-22 22:59:45]
  • 提交

answer

#include<bits/stdc++.h>
#define ll long long
using namespace std;
int N;
const char sta[5]={'R','B','N','Q','K'};
const int maks[5]={2,2,2,1,1};
string S,ans="";
vector<string> svi,pot,pom;
void proveri(){
   int b1,b2,r1,r2,k;
   for(int i=0;i<S.size();i++)
      if(S[i]=='B'){
         b1=i;
         break;
      }
   for(int i=0;i<S.size();i++)
      if(S[i]=='B'){
         b2=i;
      }
   for(int i=0;i<S.size();i++)
      if(S[i]=='R'){
         r1=i;
         break;
      }
   for(int i=0;i<S.size();i++)
      if(S[i]=='R'){
         r2=i;
      }
   for(int i=0;i<S.size();i++)
      if(S[i]=='K'){
         k=i;
         break;
      }
   if(b1%2==b2%2)
      return;
   if(r1>k)
      return;
   if(r2<k)
      return;
   svi.push_back(S);
   return;
}
void rek(int kol[5]){
   for(int i=0;i<=4;i++)
      if(kol[i]>maks[i])
         return;
   if(S.size()==8){
      proveri();
      return;
   }
   for(int i=0;i<=4;i++){
      S.push_back(sta[i]);
      kol[i]++;
      rek(kol);
      kol[i]--;
      S.pop_back();
   }
   return;
}
int comp(string a,string b){
   int r=0;
   for(int i=0;i<a.size();i++)
      r+=(a[i]==b[i]);
   return r;
}
int getskor(string Q){
   int kol[10]={0,0,0,0,0,0,0,0,0,0};
   for(int i=0;i<pot.size();i++)
      kol[comp(Q,pot[i])]++;
   int maks=0;
   for(int i=0;i<=8;i++)
      maks=max(maks,kol[i]);
   return maks;
}
string getbest(){
   string best="";
   int skor=1e9;
   for(int i=0;i<svi.size();i++){
      int s=getskor(svi[i]);
      if(s<skor){
         skor=s;
         best=svi[i];
      }
   }
   return best;
}
int query(string a){
   cout<<a<<endl;
   ll r;
   if(ans!=""){
      r=comp(a,ans);
      cout<<"> "<<r<<endl;
      return r;
   }
   cin>>r;
   return r;
}
void solve(){
   pot=svi;
   while(pot.size()>1){
   //   cout<<pot.size()<<endl;
      string g=getbest();
      int r=query(g);
      if(r==8)
         return;
      pom.clear();
      for(int i=0;i<pot.size();i++)
         if(comp(pot[i],g)==r)
            pom.push_back(pot[i]);
      pot=pom;
   }
   query(pot[0]);
}
int main(){
   int niz[5]={0,0,0,0,0};
   rek(niz);
   string x;
   while(true){
      cin>>x;
      if(x=="END")
         return 0;
      cin>>x;
     // cin>>ans;
      solve();
   }
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 13ms
memory: 3892kb

input:

GAME 1
4
2
6
8
END

output:

RQKBBNRN
RNBBKNQR
RKRNBQNB
RKRBBQNN

result:

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

Test #2:

score: 0
Accepted
time: 1260ms
memory: 3976kb

input:

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

output:

RQKBBNRN
RNBBKNQR
RKRNBQNB
RKRBBQNN
RQKBBNRN
RBNKBNQR
RBBNNKRQ
RKRBBNQN
RQKBBNRN
RNBBKNQR
RNKBBQNR
RBNNBKRQ
RKRBBNNQ
RQKBBNRN
RNBBKNQR
RNKBBQNR
RBNKQRBN
RKRBQNBN
RQKBBNRN
NRNBBKQR
RBNQNKBR
RBBNNKRQ
RBBNNQKR
RKRBNQBN
RQKBBNRN
NRNBBKQR
RBNQNKBR
RBBNNKRQ
RBBNQNKR
RKRBNNBQ
RQKBBNRN
NRNBBKQR
RBNQNKBR
RBB...

result:

ok (c) correct after 96 tests, max moves 6 (96 test cases)

Test #3:

score: 0
Accepted
time: 1176ms
memory: 3740kb

input:

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

output:

RQKBBNRN
RNBBKNQR
RBBNNKRQ
RBBNNQKR
RKQBBNNR
RQKBBNRN
NRNBBKQR
RBNKBRNQ
RBBNNQKR
RKNBBQNR
RQKBBNRN
RNBBKNQR
RBNNBQKR
RBBNNQKR
RKNBBNQR
RQKBBNRN
NRNBBKQR
RNQNBKRB
RBBNNQKR
RKQBNNBR
RQKBBNRN
NRNBBKQR
RBNNBKRQ
RBBQNNKR
RKNBQNBR
RQKBBNRN
NRKBBQNR
RBNQBKNR
RKNBRQBN
RKNBNQBR
RQKBBNRN
NRKBBQNR
RBNQBKNR
RBB...

result:

ok (c) correct after 96 tests, max moves 6 (96 test cases)

Test #4:

score: 0
Accepted
time: 1260ms
memory: 3740kb

input:

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

output:

RQKBBNRN
NRNBBKQR
RNQNBKRB
RBNKRNBQ
QRKRBBNN
RQKBBNRN
NRNBBKQR
RBNKBRNQ
RBBNQKRN
NRKRBBQN
RQKBBNRN
NRKBBQNR
RBBNNQKR
RBBNNKRQ
NRKRBBNQ
RQKBBNRN
NRNBBKQR
RNQNBKRB
RBBNNQKR
QRKRBNNB
RQKBBNRN
NRKBBQNR
RBBKNQRN
RBBNNQKR
NRKRBQNB
RQKBBNRN
NRNBBKQR
RBNKBRNQ
RBBNQKRN
NRKRBNQB
RQKBBNRN
NRKBBQNR
RNQKBBNR
QRK...

result:

ok (c) correct after 96 tests, max moves 6 (96 test cases)

Test #5:

score: 0
Accepted
time: 1260ms
memory: 3688kb

input:

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

output:

RQKBBNRN
NRNBBKQR
RBNQNKBR
RBBNNKRQ
RBBNQNKR
RQNKRBBN
RQKBBNRN
NRKBBQNR
RKNNRBBQ
RBQKNRBN
RBBNNQKR
RNQKRBBN
RQKBBNRN
RNBBNKRQ
RBBNKRNQ
RBNKQNBR
RNNKRBBQ
RQKBBNRN
NRNBBKQR
RBNQNKBR
RBBNNKRQ
RBBNQNKR
RQNKRNBB
RQKBBNRN
NRKBBQNR
RKNNRBBQ
RBBQKRNN
RBBNNQKR
RNQKRNBB
RQKBBNRN
RNBBNKRQ
RKNNQRBB
RKNQNBBR
RNN...

result:

ok (c) correct after 96 tests, max moves 6 (96 test cases)

Test #6:

score: 0
Accepted
time: 1279ms
memory: 3740kb

input:

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

output:

RQKBBNRN
NRKBBQNR
RBBNKQNR
RNNQKRBB
RBBNNQKR
QRBKNBRN
RQKBBNRN
NRKBBQNR
RNQKBBNR
BBRQNNKR
RBBNNQKR
NRBKQBRN
RQKBBNRN
RNBBNKRQ
NRQNBKRB
RBBNKRNQ
NRBKNBRQ
RQKBBNRN
NRKBBQNR
RBBNKQNR
RNNQKRBB
RBBNNKRQ
QRBKNNRB
RQKBBNRN
NRKBBQNR
RNQKBBNR
QRKNNRBB
RBBNNQKR
NRBKQNRB
RQKBBNRN
RNBBNKRQ
RBBNKRNQ
BBQNRKNR
NRB...

result:

ok (c) correct after 96 tests, max moves 6 (96 test cases)

Test #7:

score: 0
Accepted
time: 1257ms
memory: 3744kb

input:

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

output:

RQKBBNRN
NRKBBQNR
RBBNKQNR
RBQKBNNR
RBBQKRNN
RQKBBNRN
NRKBBQNR
RKNNRBBQ
BBNRKQRN
RBBNNQKR
RBBNKRQN
RQKBBNRN
RNBBNKRQ
RBBNKRNQ
RQKBBNRN
NRKBBQNR
RKNNRBBQ
RBBQKRNN
RBQNKRBN
RQKBBNRN
NRKBBQNR
RKNNRBBQ
RBBQKRNN
RBNQKRBN
RQKBBNRN
RNBBNKRQ
RKNNQRBB
RBBNNQKR
RBBNNKRQ
RBNNKRBQ
RQKBBNRN
RNBBKNQR
RBBNNKRQ
RBB...

result:

ok (c) correct after 96 tests, max moves 6 (96 test cases)

Test #8:

score: 0
Accepted
time: 1269ms
memory: 3740kb

input:

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

output:

RQKBBNRN
NRKBBQNR
RBNQBKNR
RQKBNNBR
RBBNNQKR
QRNBKNBR
RQKBBNRN
NRKBBQNR
RBBQKNNR
RBBNNQKR
NRQBKNBR
RQKBBNRN
RNBBNKRQ
BBRKRNQN
RKQNNRBB
RBBNQNKR
NRNBKQBR
RQKBBNRN
BBRNNQKR
BRNKNRQB
RBQNKRBN
QRNNKBBR
RQKBBNRN
BBRNNQKR
BRNKNRQB
NBNRQKBR
NRQNKBBR
RQKBBNRN
BBRNNQKR
RNNKQBBR
RNBKQRNB
NRNQKBBR
RQKBBNRN
RNB...

result:

ok (c) correct after 96 tests, max moves 6 (96 test cases)

Test #9:

score: 0
Accepted
time: 1247ms
memory: 3708kb

input:

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

output:

RQKBBNRN
RNBBNKRQ
BBRKRNQN
BQRNNKRB
RBBNNQKR
QBBRKNNR
RQKBBNRN
BBRNNQKR
NBBRQKNR
RBBKNRQN
NBBRKQNR
RQKBBNRN
RNBBNKRQ
BBRKRNQN
RBNNBQKR
RBBNNKQR
NBBRKNQR
RQKBBNRN
RNBBNKRQ
NBRNKRBQ
RBNKBRQN
QBNRKNBR
RQKBBNRN
RNBBNKRQ
NBRNKRBQ
RBBNKNQR
NBQRKNBR
RQKBBNRN
BBRNNQKR
NBBRQKNR
RBKRNNBQ
NBNRKQBR
RQKBBNRN
BBR...

result:

ok (c) correct after 96 tests, max moves 6 (96 test cases)

Test #10:

score: 0
Accepted
time: 1275ms
memory: 3744kb

input:

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

output:

RQKBBNRN
BBRNNQKR
BNRQKBNR
RBBNNKRQ
BBRQNKNR
RQKBBNRN
BBRNNQKR
BNRQKBNR
BBRNQKNR
RQKBBNRN
BBRNNQKR
RBBNKNQR
RBBNNKRQ
BBRNNKQR
RQKBBNRN
NRKBBQNR
RBNQBKNR
RKNBRQBN
RBBNNKRQ
BQRBNKNR
RQKBBNRN
RNBBNKRQ
RBBNKRNQ
BBQNRKNR
RBBNNQKR
BNRBQKNR
RQKBBNRN
RNBBNKRQ
NRQNBKRB
BBNQRKNR
BNRBNKQR
RQKBBNRN
RNBBNKRQ
BBR...

result:

ok (c) correct after 96 tests, max moves 6 (96 test cases)

Test #11:

score: 0
Accepted
time: 1270ms
memory: 3680kb

input:

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

output:

RQKBBNRN
RBNKBNQR
RBNKBQRN
RQNBBNKR
RQKBBNRN
RNBBKNQR
RBNNBQKR
RBBNNQKR
RNQBBNKR
RQKBBNRN
NRNBBKQR
RBNKBRNQ
RBBNNQKR
RNNBBQKR
RQKBBNRN
NRNBBKQR
RBNNBKRQ
RBBQNNKR
RQNNBBKR
RQKBBNRN
NRKBBQNR
RNQKBBNR
RBBNNQKR
RNQNBBKR
RQKBBNRN
NRKBBQNR
RNQKBBNR
RBBNNQKR
RNNQBBKR
RQKBBNRN
NRKBBQNR
RBNQBKNR
BRKRQBNN
RBB...

result:

ok (c) correct after 96 tests, max moves 6 (96 test cases)

Extra Test:

score: 0
Extra Test Passed