QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#492262#7179. Fischer's Chess Guessing Gameno_RED_no_DEADCompile Error//C++201.6kb2024-07-26 10:55:252024-07-26 10:55:25

Judging History

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

  • [2024-07-26 10:55:25]
  • 评测
  • [2024-07-26 10:55:25]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

int main() {
	string piece = "KQRRBBNN";
	sort(piece.begin(), piece.end());
	vector<string> cand;
	do {
		// the king is placed between the two rooks
		int l = piece.find('R');
		int r = piece.find_last_of('R');
		int k = piece.find('K');
		if (k < l || k > r) {
			continue;
		}
		// the white bishop s are placed on opposite-colored squares
		int b1 = piece.find('B');
		int b2 = piece.find_last_of('B');
		if (b1 % 2 == b2 % 2) {
			continue;
		}
		cand.push_back(piece);
	} while (next_permutation(piece.begin(), piece.end()));


	string str;
	while (cin >> str) {
		if (str == "END") {
			break;
		}
		cin >> *new int;
		auto cur = cand;

		while (1) {
			double best = numeric_limits<double>::max();
			string base;
			if (cur.size() == 960) {
				base = "RBBNNQKR";
			} else {
                // DONE UP HERE
				for (auto x : cur) {
					array<int, 9> freq{};
					for (auto y : cur) {
						int cnt = 0;
						for (int i = 0; i < 8; i++) {
							if (x[i] == y[i]) {
								cnt++;
							}
						}
						freq[cnt]++;
					}
					double sum = 0;
					for (int x : freq) {
						if (x) {
							sum += x * sqrt(n);
						}
					}
					if (sum < best) {
						best = sum;
						base = x;
					}
				}
			}
			cout << base << endl;
			int num;
			cin >> num;
			if (num == 8) {
				break;
			}
			vector<string> ncur;
			for (auto x : cur) {
				int cnt = 0;
				for (int i = 0; i < 8; i++) {
					if (x[i] == base[i]) {
						cnt++;
					}
				}
				if (cnt == num) {
					ncur.push_back(x);
				}
			}
			cur = move(ncur);
		}
	}
	return 0;
}

Details

answer.code: In function ‘int main()’:
answer.code:55:73: error: ‘n’ was not declared in this scope
   55 |                                                         sum += x * sqrt(n);
      |                                                                         ^