QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#291851#7179. Fischer's Chess Guessing GameOAleksaWA 86ms3920kbC++142.4kb2023-12-27 09:49:162023-12-27 09:49:17

Judging History

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

  • [2023-12-27 09:49:17]
  • 评测
  • 测评结果:WA
  • 用时:86ms
  • 内存:3920kb
  • [2023-12-27 09:49:16]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define f first
#define s second
#define int long long
const int N = 960;
vector<int> g(N);
vector<char> sv = {'K', 'Q', 'N', 'N', 'B', 'B', 'R', 'R'};
vector<string> perm;
int good(vector<char> ord) {
	int x = -1, y = -1, z = -1, b = -1, a = -1;
	for (int i = 0;i < 8;i++) {
		if (ord[i] == 'K')
			z = i;
		else if (ord[i] == 'B') {
			if (x == -1)
				x = i;
			else
				y = i;
		}
		else if (ord[i] == 'R') {
			if (a == -1)
				a = i;
			else
				b = i;
		}
	}
	return z < b && z > a && x % 2 != y % 2;
};
int diff(string a, string b) {
	int r = 0;
	for (int i = 0;i < 8;i++)
		r += (a[i] == b[i]);
	return r;
};
string ans;
void resi(int r) {
	int x = 0;
	for (int i = 0;i < N;i++) {
		if (diff(perm[i], ans) != r) {
			g[i] = false;
			x++;
		}
	}
	int mn = 1e9;
	for (int i = 0;i < N;i++) {
		if (!g[i])
			continue;
		int mx = 0;
		vector<int> cnt(10);
		for (int j = 0;j < N;j++) {
			if (!g[j])
				continue;
			mx = max(mx, ++cnt[diff(perm[i], perm[j])]);
		}
		if (mx < mn) {
			mn = mx;
			ans = perm[i];
		}
	}
	//cout << mn << " " << x << endl;
}
signed main() {
	ios_base::sync_with_stdio(false);
  cout.tie(nullptr); 
  cin.tie(nullptr);
  //freopen("newbarn.in", "r", stdin);
  //freopen(newbarn.out", "w", stdout);
  int tt = 1;
  //cin >> tt;
  while (tt--) {
  	vector<int> order(8);
  	iota(order.begin(), order.end(), 0);
  	map<string, int> bio;
  	while (next_permutation(order.begin(), order.end())) {
  		vector<char> t;
  		for (int i = 0;i < 8;i++)
  			t.push_back(sv[order[i]]);
  		if (good(t)) {
  			string s;
  			for (auto x : t)
  				s += x;
  			if (bio[s])
  				continue;
  			bio[s] = 1;
  			perm.push_back(s);
  		}
  	}
  	int mx = 1e9;
  	string ans1;
  	for (int i = 0;i < 960;i++) {
  		vector<int> cnt(10);
  		int l = 0;
  		for (int j = 0;j < 960;j++) 
  			l = max(l, ++cnt[diff(perm[i], perm[j])]);
  		if (l < mx) {
  			ans1 = perm[i];
  			mx = l;
  		}
  	}
  	while (true) {
  		string s;
  		cin >> s;
  		if (s == "GAME") {
  			ans = ans1;
  			for (int i = 0;i < N;i++)
  				g[i] = 1;
  			cin >> s;
  			int c = 0;
  			while (true) {
  				cout << ans << endl;
  				c++;
  				int r;
  				cin >> r;
  				if (r == 8 || c > 6)
  					break;
  				resi(r);
  			}
  		}
  		else
  			break;
  	}
  }
  return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 15ms
memory: 3648kb

input:

GAME 1
2
2
1
8
END

output:

NRNBBKQR
RNQNBBKR
BBQRNKNR
RKRBBQNN

result:

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

Test #2:

score: 0
Accepted
time: 86ms
memory: 3720kb

input:

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

output:

NRNBBKQR
RNQNBBKR
BBQRNKNR
RKRBBQNN
NRNBBKQR
NRKQBBRN
RBNQBNKR
NBBQRKNR
RKRBBNQN
NRNBBKQR
RNQNBBKR
BBQRNKNR
RKRBBQNN
RKRBBNNQ
NRNBBKQR
BQNRKRNB
QNRKNBBR
RNKBRQBN
RKRBQNBN
NRNBBKQR
BQNRKRNB
QNRKNBBR
NBRKRQBN
QBRKBNRN
RKRBNQBN
NRNBBKQR
BQNRKRNB
QNRKNBBR
NBRKRQBN
RKRBNNBQ
NRNBBKQR
BQNRKRNB
QBBNNRKR
BNR...

result:

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

Test #3:

score: 0
Accepted
time: 84ms
memory: 3728kb

input:

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

output:

NRNBBKQR
NRKQBBRN
NQBBRNKR
QBNRBNKR
NBBRQKNR
RKQBBNNR
NRNBBKQR
BNRBNKQR
QBNRBKNR
QRKBBNNR
RKNBBQNR
NRNBBKQR
NRKBBQNR
QRNBNKBR
NNBBRKQR
RKNBBNQR
NRNBBKQR
RNQNBBKR
RBKNBRQN
RKQBNNBR
NRNBBKQR
NRKQBBRN
QBNRNKBR
BQNBNRKR
RKNBQNBR
NRNBBKQR
NRKQBBRN
QBNRNKBR
BBNRKNQR
RKNBNQBR
NRNBBKQR
RNQNBBKR
RKQNBBNR
NRN...

result:

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

Test #4:

score: 0
Accepted
time: 81ms
memory: 3920kb

input:

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

output:

NRNBBKQR
RNQNBBKR
BBQRNKNR
NBBQRNKR
QRKRBBNN
NRNBBKQR
BNRBNKQR
NRKNBRQB
NRKBBRNQ
NRKRBBQN
NRNBBKQR
NRKQBBRN
NRKQBRNB
NRKNBQRB
NRKRBBNQ
NRNBBKQR
RNQNBBKR
QRBNNKRB
NRKNQRBB
QRKRBNNB
NRNBBKQR
NRKQBBRN
NRKNQBBR
NNRQBBKR
NRKRBQNB
NRNBBKQR
BNRBNKQR
NRKNBRQB
NRKRBNQB
NRNBBKQR
BQNRKRNB
QBBNNRKR
QRKNRNBB
QRK...

result:

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

Test #5:

score: -100
Wrong Answer
time: 25ms
memory: 3872kb

input:

GAME 1
1
2
1
4
4
8
GAME 2
0
1
5
3
8
GAME 3
1
1
0
4
4
8
GAME 4
1
3
2
3
1
8
GAME 5
0
0
2
3
8
GAME 6
1
2
2
0
8
GAME 7
0
2
3
3
8
GAME 8
1
1
4
4
8
GAME 9
0
1
2
1
8
GAME 10
1
2
2
0
2
8
GAME 11
3
2
4
3
4
8
GAME 12
2
2
2
1
2
2

output:

NRNBBKQR
BQNRKRNB
BRQKNNRB
RKNNRQBB
RKNRNBBQ
RQNKRBBN
NRNBBKQR
BBRNKQRN
RKQRNBBN
RKBRQBNN
RNQKRBBN
NRNBBKQR
BQNRKRNB
QBBNNRKR
BNRKRBQN
NNRKRQBB
RNNKRBBQ
NRNBBKQR
BQNRKRNB
BQRKNBNR
RNQKBRNB
BNQRNKRB
RQNKRNBB
NRNBBKQR
BBRNKQRN
RKBQNRNB
RNKRNBBQ
RNQKRNBB
NRNBBKQR
BQNRKRNB
BRQKNNRB
BQRNNBKR
RNNKRQBB
NRN...

result:

wrong answer (i) too many guesses in game 12, pos =