QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#430156#7179. Fischer's Chess Guessing GamePhysics212303AC ✓111ms7520kbC++171.2kb2024-06-03 15:23:322024-06-03 15:23:32

Judging History

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

  • [2024-06-03 15:23:32]
  • 评测
  • 测评结果:AC
  • 用时:111ms
  • 内存:7520kb
  • [2024-06-03 15:23:32]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
const int C=960;
int K,Q,R,B,N;
vector<string> s;
void dfs(string a){
  if(a.length()==8){
    int c=0;
    for(int i=0;i<8;i++)
      if(a[i]=='B')c^=i;
    if(c&1)s.emplace_back(a);
    return;
  }
  if(R==1&&!K)K++,dfs(a+'K'),K--;
  if(!Q)Q++,dfs(a+'Q'),Q--;
  if(!R||R==1&&K)R++,dfs(a+'R'),R--;
  if(N<2)N++,dfs(a+'N'),N--;
  if(B<2)B++,dfs(a+'B'),B--;
}
int ask(string s){
  cout<<s<<endl;
  int x; cin>>x;
  return x;
}
int main(){
  ios::sync_with_stdio(false);
  dfs("");
  vector d(C,vector<int>(C));
  for(int i=0;i<C;i++)
    for(int j=0;j<C;j++)
      for(int k=0;k<8;k++)
        d[i][j]+=s[i][k]==s[j][k];
  string g; while(cin>>g){
    if(g[0]=='E')break;
    int x; cin>>x;
    vector<int> p(C);
    iota(p.begin(),p.end(),0);
    while(1){
      if(p.size()==1){ask(s[p[0]]); break;}
      int f=C+1,r;
      for(int i=0;i<C;i++){
        vector<int> c(9);
        for(int j:p)c[d[i][j]]++;
        int m=*max_element(c.begin(),c.end());
        if(m<f)f=m,r=i;
      }
      int x=ask(s[r]); if(x==8)break;
      vector<int> v;
      for(int i:p)if(d[i][r]==x)v.emplace_back(i);
      p=v;
    }
  }
  return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 8ms
memory: 7520kb

input:

GAME 1
3
0
4
4
0
8
END

output:

RQKNBBRN
NRKQNBBR
RKNQBRNB
QRKBBRNN
QRKNNRBB
RKRBBQNN

result:

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

Test #2:

score: 0
Accepted
time: 102ms
memory: 7336kb

input:

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

output:

RQKNBBRN
NRKQNBBR
RKNQBRNB
QRKBBRNN
QRKNNRBB
RKRBBQNN
RQKNBBRN
NRKQNBBR
RKNQBRNB
QNNRBKRB
RKRBBNQN
RQKNBBRN
NRKQBBNR
QNNRBBKR
QRKBRNBN
QRKNNBBR
RKRBBNNQ
RQKNBBRN
NRKQBBNR
BNRNQKRB
QBBRKNRN
QRKRNBBN
RKRBQNBN
RQKNBBRN
NRKQBBNR
BNRNQKRB
RNKBQRBN
RKRBNQBN
RQKNBBRN
RQBKNNRB
RKNBNQBR
QRKNNRBB
RKRBNNBQ
RQK...

result:

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

Test #3:

score: 0
Accepted
time: 98ms
memory: 7212kb

input:

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

output:

RQKNBBRN
NRKQBBNR
RBNNBKQR
QNRNKBBR
QRKRNNBB
RKQBBNNR
RQKNBBRN
NRKQBBNR
RBNNBKQR
RNKBBRNQ
RKNBBQNR
RQKNBBRN
NRKQBBNR
QNNRBBKR
QRNNBKRB
QRKBRNBN
RKNBBNQR
RQKNBBRN
RQBKNNRB
RKNBNQBR
QRKRNNBB
RKQBNNBR
RQKNBBRN
RQBKNNRB
QRBKNRNB
QNRBKNBR
QRKBRNBN
RKNBQNBR
RQKNBBRN
RQBKNNRB
QRBKNRNB
QRKBNNBR
QNBRNKRB
RKN...

result:

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

Test #4:

score: 0
Accepted
time: 101ms
memory: 7488kb

input:

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

output:

RQKNBBRN
QRKNBRNB
QRKRNNBB
QRKRBBNN
RQKNBBRN
QRKNBRNB
QRKRNBBN
NRKRBBQN
RQKNBBRN
NRKQNBBR
RKQRNNBB
QRKRBNNB
NRKRBBNQ
RQKNBBRN
NRKQBBNR
RQBNKBNR
QRKRNNBB
QRKRBNNB
RQKNBBRN
NRKQBBNR
QRKRNNBB
QRKNRNBB
NRKRBQNB
RQKNBBRN
NRKQBBNR
RQBNKBNR
QRKRNNBB
NRKRBNQB
RQKNBBRN
NRKQNBBR
QRNBKRBN
QRKRNBBN
RQKNBBRN
NRK...

result:

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

Test #5:

score: 0
Accepted
time: 107ms
memory: 7264kb

input:

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

output:

RQKNBBRN
QRKNBRNB
QNBRKBRN
RQNKRBBN
RQKNBBRN
NRKQNBBR
QNRBBKNR
QRKNRNBB
QRKRNNBB
RNQKRBBN
RQKNBBRN
NRKQBBNR
RBBQKNNR
QRNKBNRB
QRKRBNNB
RNNKRBBQ
RQKNBBRN
NRKQBBNR
BNRNQKRB
RNKBQRBN
QRKRNNBB
RQNKRNBB
RQKNBBRN
RQBKNNRB
RKBRNBNQ
RNQKNRBB
RNQKRNBB
RQKNBBRN
RQBKNNRB
RKNBNQBR
QRKNRNBB
QRKRNNBB
RNNKRQBB
RQK...

result:

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

Test #6:

score: 0
Accepted
time: 101ms
memory: 7260kb

input:

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

output:

RQKNBBRN
NRKQNBBR
QRKBNRBN
QRKRBBNN
QRBKNBRN
RQKNBBRN
NRKQNBBR
QRKBNRBN
QRKRBBNN
QRNNKRBB
NRBKQBRN
RQKNBBRN
NRKQBBNR
RBNNBKQR
QRKBBRNN
NRBKNBRQ
RQKNBBRN
RQBKNNRB
QRBKNNRB
RQKNBBRN
RQBKNNRB
QRKNBNRB
QRKRNNBB
NRBKQNRB
RQKNBBRN
RQBKNNRB
QRKNBNRB
NRBKNQRB
RQKNBBRN
QRKNBRNB
QRKRNBBN
QRNKBNRB
QRNKBBRN
RQK...

result:

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

Test #7:

score: 0
Accepted
time: 107ms
memory: 7252kb

input:

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

output:

RQKNBBRN
NRKQBBNR
QNNRBBKR
QRKBNNBR
QRKRBNNB
RBBQKRNN
RQKNBBRN
NRKQNBBR
RKNQBRNB
QRNNBKRB
QRKRNNBB
RBBNKRQN
RQKNBBRN
NRKQBBNR
RBBQKNNR
QRKNNBBR
RBBNKRNQ
RQKNBBRN
NRKQNBBR
QNBRNKRB
QBRNBNKR
RBQNKRBN
RQKNBBRN
NRKQBBNR
RBBQKNNR
RQNBNKBR
QRKRNBBN
RBNQKRBN
RQKNBBRN
NRKQBBNR
BNRNQKRB
RNKBQRBN
QRKRNNBB
RBN...

result:

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

Test #8:

score: 0
Accepted
time: 111ms
memory: 7260kb

input:

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

output:

RQKNBBRN
BBQRNNKR
QRNBBKNR
QRKRNNBB
QRNBKNBR
RQKNBBRN
BBQRNNKR
RNNBBKQR
QRKBRNBN
NRQBKNBR
RQKNBBRN
BBQRNNKR
BQRKNRNB
QNRNBKRB
NRNBKQBR
RQKNBBRN
NRKQBBNR
RBNNBKQR
QNRNKBBR
QRNNKBBR
RQKNBBRN
NRKQBBNR
RQBNKBNR
QRKRNNBB
NRQNKBBR
RQKNBBRN
RQBKNNRB
QBRNBKNR
QRBBKRNN
NRNQKBBR
RQKNBBRN
RQBKNNRB
QBRNBKNR
RBN...

result:

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

Test #9:

score: 0
Accepted
time: 94ms
memory: 7520kb

input:

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

output:

RQKNBBRN
BBQRNNKR
QRNBKNBR
QRNBNKBR
QBBRKNNR
RQKNBBRN
BBQRNNKR
RNNBBKQR
QBRNKNBR
NBBRKQNR
RQKNBBRN
BBQRNNKR
QRNBKNBR
RBBNKNQR
NBBRKNQR
RQKNBBRN
BBQRNNKR
QRNBKNBR
QBNRKNBR
RQKNBBRN
BBQRNNKR
QNRBKNBR
QRKRNNBB
NBQRKNBR
RQKNBBRN
BBQRNNKR
RNNBBKQR
QRKBRNBN
QRKRBNNB
NBNRKQBR
RQKNBBRN
RQBKNNRB
NBBRNQKR
QRK...

result:

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

Test #10:

score: 0
Accepted
time: 101ms
memory: 7324kb

input:

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

output:

RQKNBBRN
BBQRNNKR
QRNBKNBR
QNRKBRNB
BBRQNKNR
RQKNBBRN
RQBKNNRB
QBRNBKNR
QRKRBNNB
BBRNQKNR
RQKNBBRN
RQBKNNRB
NBBRNQKR
QRKRBBNN
QRKNRNBB
BBRNNKQR
RQKNBBRN
RQBKNNRB
QRBKNRNB
QRNKRNBB
QRNBNKBR
BQRBNKNR
RQKNBBRN
BBQRNNKR
QRNBBKNR
QRNKNRBB
BNRBQKNR
RQKNBBRN
BBQRNNKR
RNNBBKQR
QRKRNNBB
BNRBNKQR
RQKNBBRN
NRK...

result:

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

Test #11:

score: 0
Accepted
time: 110ms
memory: 7252kb

input:

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

output:

RQKNBBRN
NRKQNBBR
QNBRNKRB
QBRNBNKR
RQNBBNKR
RQKNBBRN
NRKQBBNR
QNNRBBKR
QRNBKRBN
QRKRNNBB
RNQBBNKR
RQKNBBRN
NRKQBBNR
QNNRBBKR
QRKRNBBN
RNNBBQKR
RQKNBBRN
RKNNBRQB
QRKNRNBB
RQNNBBKR
RQKNBBRN
QRKNBRNB
QRNKBNRB
QNNRBBKR
RNQNBBKR
RQKNBBRN
NRKQNBBR
QRKBNRBN
RKRBBQNN
RNNQBBKR
RQKNBBRN
BBQRNNKR
QRNBBNKR
BRQ...

result:

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

Extra Test:

score: 0
Extra Test Passed