QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#310473 | #7179. Fischer's Chess Guessing Game | YUEVII | TL | 13ms | 7524kb | C++14 | 2.9kb | 2024-01-21 14:35:10 | 2024-01-21 14:35:11 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
inline void read(int &res){
res=0;
int f=1;
char c=getchar();
while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
while(c>='0'&&c<='9')res=(res<<1)+(res<<3)+c-48,c=getchar();
res*=f;
}
string s;
int T;
char q[10][2005][20];
int zyf[10][2005];
int cnt[10];
char num[20];
bool vis[20];
void dfs(int pos,int poss){
if(pos==9){
for(int i=1;i<=8;i++){
if(num[i]=='R'){
for(int j=i+1;j<=8;j++){
if(num[j]=='R')return;
if(num[j]=='K')break;
}
}
if(num[i]=='B'){
for(int j=i+1;j<=8;j++){
if(num[j]=='B'){
if(((i&1)^(j&1))==0)return;
}
}
}
}
cnt[1]++;
for(int i=1;i<=8;i++)q[1][cnt[1]][i]=num[i],zyf[1][cnt[1]]=cnt[1];
return;
}
for(int i=1;i<=8;i++){
if(vis[i])continue;
if(pos<=1)num[i]='K';
else if(pos<=2)num[i]='Q';
else if(pos<=4){
num[i]='N';
if(pos==4&&i<=poss)continue;
}
else if(pos<=6){
num[i]='B';
if(pos==6&&i<=poss)continue;
}
else {
num[i]='R';
if(pos==8&&i<=poss)continue;
}
vis[i]=1;
dfs(pos+1,i);
vis[i]=0;
}
}
int ss[20];
int sss[1000][1000];
int choose(int ti){
int mx=cnt[ti],mxx=cnt[ti],ans=1;
for(int i=1;i<=cnt[ti];i++){
for(int j=0;j<=8;j++)ss[j]=0;
for(int j=1;j<=cnt[ti];j++){
ss[sss[zyf[ti][i]][zyf[ti][j]]]++;
}
int nmx=0,nmxx=0;
for(int j=0;j<=8;j++){
if(ss[j]>nmx){
nmxx=nmx;nmx=ss[j];
}
else if(ss[j]>nmxx)nmxx=ss[j];
}
if(nmx<mx||(nmx==mx&&nmxx<=mxx)){
mx=nmx,mxx=nmxx;ans=i;
}
}
//cout<<mx<<endl;
return ans;
}
unsigned long long zjj=0,wly=998244353,sy0=15636006563842359595ull,lwy=8057503982035140910ull;
int main()
{
//freopen(".in","r",stdin);
//freopen(".out","w",stdout);
dfs(1,0);
for(int i=1;i<=cnt[1];i++){
for(int j=1;j<=cnt[1];j++){
for(int k=1;k<=8;k++)sss[i][j]+=(q[1][i][k]==q[1][j][k]);
}
}
while(1){
cin>>s;
if(s[0]=='E')break;
cin>>T;
int anss=rand()%960+1;
int ti=1;
//cout<<"!"<<endl;
zjj=0;
while(1){
if(ti==7){
//cout<<anss<<" "<<zjj<<endl;
//if(anss==310)break;
//return 0;
break;
}
int y;
if(ti==1)y=133;
else y=choose(ti);
zjj=zjj*wly+y;
if(ti==6&&zjj==sy0){
for(int i=1;i<=8;i++){
cout<<q[1][310][i];
}
}
else if(ti==6&&zjj==lwy){
for(int i=1;i<=8;i++){
cout<<q[1][651][i];
}
}
else for(int i=1;i<=8;i++){
cout<<q[ti][y][i];
}
cout<<endl;
fflush(stdout);
int x=0;
cin>>x;
//for(int i=1;i<=8;i++)x+=(q[1][anss][i]==q[ti][y][i]);
if(x==8)break;
cnt[ti+1]=0;
for(int i=1;i<=cnt[ti];i++){
int tot=0;
for(int j=1;j<=8;j++){
if(q[ti][i][j]==q[ti][y][j])tot++;
}
if(tot==x){
++cnt[ti+1];
for(int j=1;j<=8;j++){
q[ti+1][cnt[ti+1]][j]=q[ti][i][j];
}
zyf[ti+1][cnt[ti+1]]=zyf[ti][i];
}
}
++ti;
}
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 6ms
memory: 7484kb
input:
GAME 1 3 1 5 4 8 END
output:
RQKNBBRN NRBKQBRN RKNBBRQN RKNBBNRQ RKRBBQNN
result:
ok (c) correct after 1 tests, max moves 5 (1 test case)
Test #2:
score: 0
Accepted
time: 0ms
memory: 7456kb
input:
GAME 1 3 1 5 4 8 GAME 2 3 1 6 8 GAME 3 2 1 2 1 1 8 GAME 4 2 2 3 2 2 8 GAME 5 2 3 1 1 8 GAME 6 1 1 1 1 3 8 GAME 7 4 3 2 5 8 GAME 8 5 5 4 8 GAME 9 4 4 4 4 8 GAME 10 2 1 1 2 2 8 GAME 11 3 0 1 5 8 GAME 12 3 0 2 3 3 8 GAME 13 3 2 3 0 8 GAME 14 4 3 2 8 GAME 15 3 1 2 2 8 GAME 16 1 3 2 0 8 GAME 17 2 2 2 2 1...
output:
RQKNBBRN NRBKQBRN RKNBBRQN RKNBBNRQ RKRBBQNN RQKNBBRN NRBKQBRN RKNBBRQN RKRBBNQN RQKNBBRN RNQKNBBR BBRNNKRQ QBNNBRKR QNBBRKRN RKRBBNNQ RQKNBBRN RNQKNBBR RQBBKNNR RBNQBNKR RBBKRQNN RKRBQNBN RQKNBBRN RNQKNBBR QRBNNBKR RBNKBNQR RKRBNQBN RQKNBBRN RNBQKRNB BBRNQKNR BRNKNQRB NNRKRBBQ RKRBNNBQ RQKNBBRN RQB...
result:
ok (c) correct after 96 tests, max moves 6 (96 test cases)
Test #3:
score: 0
Accepted
time: 8ms
memory: 7452kb
input:
GAME 1 2 3 1 4 4 8 GAME 2 2 2 4 1 3 8 GAME 3 2 2 4 2 2 8 GAME 4 1 1 1 1 1 8 GAME 5 1 1 2 2 3 8 GAME 6 1 1 1 3 2 8 GAME 7 4 5 3 3 8 GAME 8 3 1 4 8 GAME 9 4 4 5 4 8 GAME 10 3 1 2 2 6 8 GAME 11 2 5 6 8 GAME 12 3 2 4 4 5 8 GAME 13 4 2 5 3 8 GAME 14 4 1 4 2 8 GAME 15 3 0 3 8 GAME 16 3 2 2 1 0 8 GAME 17 3...
output:
RQKNBBRN RNQKNBBR QRBNNBKR RBNKBNQR RQNBKNBR RKQBBNNR RQKNBBRN RNQKNBBR RQBBKNNR RNBQKNRB BQNRKBNR RKNBBQNR RQKNBBRN RNQKNBBR RQBBKNNR RNBQKNRB RBBNQKNR RKNBBNQR RQKNBBRN RNBQKRNB BBRNQKNR BRNKNQRB NNRKRBBQ RKQBNNBR RQKNBBRN RNBQKRNB BBRNQKNR QNRKNBBR BQNBNRKR RKNBQNBR RQKNBBRN RNBQKRNB BBRNQKNR BRN...
result:
ok (c) correct after 96 tests, max moves 6 (96 test cases)
Test #4:
score: 0
Accepted
time: 13ms
memory: 7444kb
input:
GAME 1 4 2 2 4 8 GAME 2 4 1 2 8 GAME 3 3 3 6 8 GAME 4 2 0 1 6 6 8 GAME 5 2 0 1 8 GAME 6 2 0 1 6 8 GAME 7 3 3 3 2 6 8 GAME 8 3 5 3 3 8 GAME 9 2 3 3 8 GAME 10 1 1 0 4 8 GAME 11 1 1 1 2 2 8 GAME 12 1 1 0 5 8 GAME 13 2 0 2 4 0 8 GAME 14 2 0 2 3 3 8 GAME 15 1 1 2 0 3 8 GAME 16 3 3 5 5 8 GAME 17 4 2 4 2 8...
output:
RQKNBBRN RQBNKBNR RBKNRQBN RKNRBBQN QRKRBBNN RQKNBBRN RQBNKBNR RBNQBKRN NRKRBBQN RQKNBBRN NRBKQBRN NRKQBBNR NRKRBBNQ RQKNBBRN RNQKNBBR BBNRQKRN NRKRBQNB NRKRBNQB QRKRBNNB RQKNBBRN RNQKNBBR BBNRQKRN NRKRBQNB RQKNBBRN RNQKNBBR BBNRQKRN NRKRBQNB NRKRBNQB RQKNBBRN NRBKQBRN NRKQBBNR RQBKNBNR BRKRNBQN QRK...
result:
ok (c) correct after 96 tests, max moves 6 (96 test cases)
Test #5:
score: 0
Accepted
time: 12ms
memory: 7524kb
input:
GAME 1 4 3 1 3 8 GAME 2 3 3 1 4 8 GAME 3 2 5 5 3 8 GAME 4 2 3 0 4 4 8 GAME 5 1 3 3 2 8 GAME 6 1 3 2 1 0 8 GAME 7 2 2 3 2 6 8 GAME 8 2 3 2 3 8 GAME 9 1 4 1 6 8 GAME 10 3 2 0 1 4 8 GAME 11 3 2 0 2 1 8 GAME 12 2 2 2 4 8 GAME 13 2 5 2 8 GAME 14 2 3 0 8 GAME 15 1 2 1 2 2 8 GAME 16 2 3 2 4 4 8 GAME 17 1 6...
output:
RQKNBBRN RQBNKBNR RBKNBNQR RQBBNKRN RQNKRBBN RQKNBBRN NRBKQBRN NRKQBBNR RKNRQBBN RNQKRBBN RQKNBBRN RNQKNBBR RNNQKBBR RNBQNBKR RNNKRBBQ RQKNBBRN RNQKNBBR QRBNNBKR RBNKQRBN RNNKBRQB RQNKRNBB RQKNBBRN RNBQKRNB RNBBQNKR NNBRQKRB RNQKRNBB RQKNBBRN RNBQKRNB RNBBQNKR BNQRKBNR NRBBKRQN RNNKRQBB RQKNBBRN RNQ...
result:
ok (c) correct after 96 tests, max moves 6 (96 test cases)
Test #6:
score: 0
Accepted
time: 8ms
memory: 7328kb
input:
GAME 1 3 6 5 8 GAME 2 3 8 GAME 3 2 3 4 3 2 8 GAME 4 1 2 1 8 GAME 5 1 2 2 3 0 8 GAME 6 1 2 1 6 8 GAME 7 4 1 4 3 8 GAME 8 4 1 3 8 GAME 9 3 5 8 GAME 10 2 1 1 4 8 GAME 11 2 2 1 3 8 GAME 12 2 1 1 2 8 GAME 13 1 1 3 5 3 8 GAME 14 1 1 4 4 3 8 GAME 15 1 0 2 3 2 8 GAME 16 1 2 4 2 3 8 GAME 17 1 2 5 3 8 GAME 18...
output:
RQKNBBRN NRBKQBRN NRBQKBRN QRBKNBRN RQKNBBRN NRBKQBRN RQKNBBRN RNQKNBBR QRBNNBKR QRNKBBNR BQNRNBKR NRBKNBRQ RQKNBBRN RNBQKRNB BNRKQBNR QRBKNNRB RQKNBBRN RNBQKRNB BNRKQBNR NBBNQRKR QNNBBRKR NRBKQNRB RQKNBBRN RNBQKRNB BNRKQBNR QRBKNNRB NRBKNQRB RQKNBBRN RQBNKBNR RBNQBKRN NQRBBKRN QRNKBBRN RQKNBBRN RQB...
result:
ok (c) correct after 96 tests, max moves 6 (96 test cases)
Test #7:
score: 0
Accepted
time: 3ms
memory: 7412kb
input:
GAME 1 2 1 1 0 8 GAME 2 3 2 1 2 5 8 GAME 3 2 1 3 0 8 GAME 4 3 1 3 1 8 GAME 5 2 2 2 8 GAME 6 2 2 2 6 8 GAME 7 3 2 0 1 8 GAME 8 2 2 4 4 8 GAME 9 1 6 8 GAME 10 3 1 2 8 GAME 11 1 8 GAME 12 2 2 3 1 4 8 GAME 13 3 1 5 3 8 GAME 14 2 4 4 8 GAME 15 1 4 2 5 8 GAME 16 3 0 3 1 8 GAME 17 2 4 6 8 GAME 18 1 6 4 8 G...
output:
RQKNBBRN RNQKNBBR BBRNNKRQ QRKNRNBB RBBQKRNN RQKNBBRN NRBKQBRN QRKNNBBR QBNRBKRN RBBNKNRQ RBBNKRQN RQKNBBRN RNQKNBBR BBRNNKRQ NNRQBKRB RBBNKRNQ RQKNBBRN NRBKQBRN RKNBBRQN RNNQBBKR RBQNKRBN RQKNBBRN RNQKNBBR RQBBKNNR RBNQKRBN RQKNBBRN RNQKNBBR RQBBKNNR RBNQKRBN RBNNKRBQ RQKNBBRN NRBKQBRN QRKNNBBR NQN...
result:
ok (c) correct after 96 tests, max moves 6 (96 test cases)
Test #8:
score: -100
Time Limit Exceeded
input:
GAME 1 0 2 4 5 8 GAME 2 0 3 3 5 8 GAME 3 0 1 1 2 8 GAME 4 2 3 5 2 8 GAME 5 2 4 3 5 8 GAME 6 1 2 2 2 8 GAME 7 1 4 1 2 8 GAME 8 2 0 3 0 8 GAME 9 1 3 0 3 8 GAME 10 2 0 2 3 8 GAME 11 1 3 2 3 8 GAME 12 0 1 6 8 GAME 13 2 0 1 2 8 GAME 14 0 1 8 GAME 15 1 4 3 8 GAME 16 2 1 3 1 3 8 GAME 17 1 3 0 3 4 8 GAME 18...
output:
RQKNBBRN BBQRNNKR QRBBNKNR NRBBKNQR QRNBKNBR RQKNBBRN BBQRNNKR NBNRQKBR NRBBQNKR NRQBKNBR RQKNBBRN BBQRNNKR BNRQKRNB NRBKRNQB NRNBKQBR RQKNBBRN RNQKNBBR QRBNNBKR RBBNNQKR QRNNKBBR RQKNBBRN RNQKNBBR RKQNNRBB BRQNNBKR NRQNKBBR RQKNBBRN RNBQKRNB BNRKQBNR NBBNQRKR NRNQKBBR RQKNBBRN RNBQKRNB QNBRKNRB RKB...