QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#167468#7179. Fischer's Chess Guessing Gameucup-team266#AC ✓113ms7356kbC++142.7kb2023-09-07 15:07:342023-09-07 15:07:34

Judging History

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

  • [2023-09-07 15:07:34]
  • 评测
  • 测评结果:AC
  • 用时:113ms
  • 内存:7356kb
  • [2023-09-07 15:07:34]
  • 提交

answer

/*
Things to notice:
1. do not calculate useless values
2. do not use similar names
 
Things to check:
1. submit the correct file
2. time (it is log^2 or log)
3. memory
4. prove your naive thoughts 
5. long long
6. corner case like n=0,1,inf or n=m
7. check if there is a mistake in the ds or other tools you use
8. fileio in some oi-contest

9. module on time 
10. the number of a same divisor in a math problem
11. multi-information and queries for dp and ds problems
*/
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
const int mod=998244353;
const int inf=0x3f3f3f3f;
vector <string> sta;
char chs[8]={'B','B','K','R','R','Q','N','N'};
int ok[1005],dist[1005][1005];
int getdist(int u,int v)
{
	int r=0;
	if(sta[u][0]==sta[v][0]) r++;
	if(sta[u][1]==sta[v][1]) r++;
	if(sta[u][2]==sta[v][2]) r++;
	if(sta[u][3]==sta[v][3]) r++;
	if(sta[u][4]==sta[v][4]) r++;
	if(sta[u][5]==sta[v][5]) r++;
	if(sta[u][6]==sta[v][6]) r++;
	if(sta[u][7]==sta[v][7]) r++;
	return r;
}
int cnt[11];
void solve()
{
	while(1)
	{
		string dirt;
		cin>>dirt;
		if(dirt=="END") return;
		cin>>dirt;
		for(int i=0;i<sta.size();i++) ok[i]=1;
		vector <int> okid;
		okid.clear();
		bool fnd=0;
		for(int _=0;_<5;_++)
		{
			okid.clear();
			for(int i=0;i<sta.size();i++) if(ok[i]) okid.pb(i);
			int minn=inf,u=-1;
			for(int i=0;i<sta.size();i++)
			{
				memset(cnt,0,sizeof(cnt));
				for(int j=0;j<okid.size();j++) cnt[dist[i][okid[j]]]++;
				int mx=0;
				for(int j=0;j<=8;j++) mx=max(mx,cnt[j]);
				if(mx<minn) minn=mx,u=i;
			}
			cout<<sta[u]<<"\n";
			fflush(stdout);
			int x;
			cin>>x;
			if(x==8)  
			{
				fnd=1;
				break;
			}
			for(int j=0;j<okid.size();j++) if(dist[u][okid[j]]!=x) ok[okid[j]]=0;
		}
		if(!fnd)
		{
			okid.clear();
			for(int i=0;i<sta.size();i++) if(ok[i]) okid.pb(i);
			cout<<sta[okid[0]]<<"\n";
			fflush(stdout);
			cin>>dirt;
		}
		
//		cout<<okid.size()<<"\n";
//		assert(okid.size()==1);
		
		
	}
}
signed main()
{
	do
	{
		string s;
		for(int i=0;i<8;i++) s+=chs[i];
		bool okk=1;
		int lr=inf,rr=-1,lb=inf,rb=-1,k=-1;
		for(int i=0;i<8;i++)
		{
			if(s[i]=='B') lb=min(lb,i),rb=max(rb,i);
			if(s[i]=='K') k=i;
			if(s[i]=='R') lr=min(lr,i),rr=max(rr,i);
		}
		if(lb%2==rb%2) okk=0;
		if(k<lr||k>rr) okk=0;
		if(okk) sta.pb(s);
	}while(next_permutation(chs,chs+8));
	for(int i=0;i<sta.size();i++) for(int j=0;j<sta.size();j++) dist[i][j]=getdist(i,j);
//	cout<<sta.size()<<"\n";
//	ios::sync_with_stdio(0);
//	cin.tie(0);
	int _=1;
//	cin>>_;
	while(_--) solve();
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 7ms
memory: 7236kb

input:

GAME 1
1
0
2
4
0
8
END

output:

NRBBNKQR
BRNNKBQR
NBRKNQBR
QBRKBRNN
BBNNQRKR
RKRBBQNN

result:

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

Test #2:

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

input:

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

output:

NRBBNKQR
BRNNKBQR
NBRKNQBR
QBRKBRNN
BBNNQRKR
RKRBBQNN
NRBBNKQR
RNBBQKRN
RQKBNNBR
BBRNNQKR
BBNNRKQR
RKRBBNQN
NRBBNKQR
BRNNKBQR
NBRKNQBR
BNRKQRNB
BBNNQRKR
RKRBBNNQ
NRBBNKQR
BRNNKBQR
NBRKNQBR
QBRKBRNN
BBNNQRKR
RKRBQNBN
NRBBNKQR
RNBBQKRN
RQKBNNBR
QNRBBKNR
BBNNQRKR
RKRBNQBN
NRBBNKQR
RNBBQKRN
QNRBKNBR
BBN...

result:

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

Test #3:

score: 0
Accepted
time: 105ms
memory: 7232kb

input:

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

output:

NRBBNKQR
RNBBQKRN
QNRBKNBR
BNNQRBKR
BBQNNRKR
RKQBBNNR
NRBBNKQR
RNBBQKRN
QNRBKNBR
RBNNBQKR
BBNNQRKR
RKNBBQNR
NRBBNKQR
RBBNQKRN
BQNBRNKR
BRKRNNQB
BBNNQRKR
RKNBBNQR
NRBBNKQR
RBBNQKRN
BQNBRNKR
BBRNKNRQ
BBNNRKQR
RKQBNNBR
NRBBNKQR
RNBBQKRN
RQKBNNBR
BBNNRKQR
BBNNQRKR
RKNBQNBR
NRBBNKQR
RBBNQKRN
BQNBRNKR
BBR...

result:

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

Test #4:

score: 0
Accepted
time: 103ms
memory: 7236kb

input:

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

output:

NRBBNKQR
BRNNKBQR
BNRBKRQN
BRKQNBNR
BBNNQRKR
QRKRBBNN
NRBBNKQR
RBBNQKRN
BQNBRNKR
BNQRKRNB
BBNNQRKR
NRKRBBQN
NRBBNKQR
RNBBQKRN
BRKQNRNB
BBQNNRKR
BBNNQRKR
NRKRBBNQ
NRBBNKQR
BRNNKBQR
RKQNRBBN
BBRKNNRQ
BBNNQRKR
QRKRBNNB
NRBBNKQR
RNBBQKRN
BRKQNRNB
BBNQRNKR
BBNNQRKR
NRKRBQNB
NRBBNKQR
RBBNQKRN
BNRBQNKR
BBN...

result:

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

Test #5:

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

input:

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

output:

NRBBNKQR
RKNNRQBB
QNRKRBBN
BBNNRKRQ
BBNNQRKR
RQNKRBBN
NRBBNKQR
RKNNRQBB
BQRNKRNB
NRKQRNBB
BBNNQRKR
RNQKRBBN
NRBBNKQR
RKNNRQBB
QNRKRBBN
BBNNRKRQ
BBNNQRKR
RNNKRBBQ
NRBBNKQR
RKNNRQBB
BBNRKQRN
BBNQRNKR
BBNNQRKR
RQNKRNBB
NRBBNKQR
RKNNRQBB
QNRKRBBN
BBRKQNRN
BBNNQRKR
RNQKRNBB
NRBBNKQR
RKNNRQBB
BNNRKQRB
BBN...

result:

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

Test #6:

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

input:

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

output:

NRBBNKQR
RBBNQKRN
BBQRNKNR
BBNRQKRN
BBNNRKQR
QRBKNBRN
NRBBNKQR
RBBNQKRN
BBNNRQKR
BBNQRKNR
BBNNQRKR
NRBKQBRN
NRBBNKQR
BNRBNKRQ
BNNRQBKR
BNRBQKNR
BBNNQRKR
NRBKNBRQ
NRBBNKQR
RBBNQKRN
BBNQRKNR
BQRKNRNB
BBNNQRKR
QRBKNNRB
NRBBNKQR
RBBNQKRN
BBQRNKNR
BBRNKNRQ
BBNNQRKR
NRBKQNRB
NRBBNKQR
BNRBNKRQ
BBNNRKQR
BBN...

result:

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

Test #7:

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

input:

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

output:

NRBBNKQR
BRNNKBQR
RKQNRBBN
BBRNQKRN
BBNNRKQR
RBBQKRNN
NRBBNKQR
RNBBQKRN
RQKBNNBR
BBNRNKRQ
BBNNQRKR
RBBNKRQN
NRBBNKQR
BRNNKBQR
BNRBKRQN
BBNNRKRQ
BBNQNRKR
RBBNKRNQ
NRBBNKQR
RKNNRQBB
BQRNKRNB
NQNRKRBB
BBNNQRKR
RBQNKRBN
NRBBNKQR
RKNNRQBB
BQRNKRNB
QRNKBNRB
BBNNQRKR
RBNQKRBN
NRBBNKQR
RKNNRQBB
QNRKRBBN
BBN...

result:

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

Test #8:

score: 0
Accepted
time: 105ms
memory: 7228kb

input:

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

output:

NRBBNKQR
RBBNQKRN
BNRBQNKR
BQNBNRKR
BBNNQRKR
QRNBKNBR
NRBBNKQR
BNRBNKRQ
NQBRNBKR
BBNRKQNR
BBNNQRKR
NRQBKNBR
NRBBNKQR
BNRBNKRQ
NQBRNBKR
BBNRKQNR
BBNNQRKR
NRNBKQBR
NRBBNKQR
RNBBQKRN
BRKQNRNB
BBRQKNNR
BBNNQRKR
QRNNKBBR
NRBBNKQR
RBBNQKRN
BQNBRNKR
BBRNNQKR
BBNNQRKR
NRQNKBBR
NRBBNKQR
RBBNQKRN
BNRBQNKR
BBN...

result:

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

Test #9:

score: 0
Accepted
time: 113ms
memory: 7296kb

input:

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

output:

NRBBNKQR
RNBBQKRN
NRNKBRQB
BBRKRNNQ
BBNNQRKR
QBBRKNNR
NRBBNKQR
RBBNQKRN
BBNQRKNR
BBNRQKRN
BBNNQRKR
NBBRKQNR
NRBBNKQR
BNRBNKRQ
BRNKQBNR
BBNNRKQR
BBNNQRKR
NBBRKNQR
NRBBNKQR
BRNNKBQR
RBQNBNKR
BBNQRKNR
BBNNQRKR
QBNRKNBR
NRBBNKQR
RNBBQKRN
BRKQNRNB
BQRNKBNR
BBNNQRKR
NBQRKNBR
NRBBNKQR
RNBBQKRN
BRKQNRNB
BQR...

result:

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

Test #10:

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

input:

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

output:

NRBBNKQR
RBBNQKRN
BBNQRKNR
BBNNRKQR
BBNNQRKR
BBRQNKNR
NRBBNKQR
RNBBQKRN
QNRBKNBR
RBNNBQKR
BBNNQRKR
BBRNQKNR
NRBBNKQR
BNRBNKRQ
BBNRKNRQ
BBNNQRKR
BBNNQRKR
BBRNNKQR
NRBBNKQR
BNRBNKRQ
BBNNRKRQ
BBNNQRKR
BBNNQRKR
BQRBNKNR
NRBBNKQR
RBBNQKRN
BBNQRKNR
BRNBQKRN
BBNNQRKR
BNRBQKNR
NRBBNKQR
BQRBNNKR
NQBBRNKR
BBN...

result:

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

Test #11:

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

input:

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

output:

NRBBNKQR
RNBBQKRN
QNRBKNBR
BNNQRBKR
BBNNQRKR
RQNBBNKR
NRBBNKQR
RNBBQKRN
RQKBNNBR
QNRBBKNR
BBNNQRKR
RNQBBNKR
NRBBNKQR
RNBBQKRN
RQKBNNBR
BBRNNQKR
BBNNQRKR
RNNBBQKR
NRBBNKQR
BRNNKBQR
QNBNRBKR
BBNQNRKR
BBNNQRKR
RQNNBBKR
NRBBNKQR
BRNNKBQR
RBQNBNKR
BBNNRKQR
BBNNQRKR
RNQNBBKR
NRBBNKQR
BRNNKBQR
RBQNBNKR
BBN...

result:

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

Extra Test:

score: 0
Extra Test Passed