QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#366795#7178. BishopsGiga_Cronos#TL 0ms0kbC++234.6kb2024-03-25 08:23:192024-03-25 08:23:20

Judging History

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

  • [2024-03-25 08:23:20]
  • 评测
  • 测评结果:TL
  • 用时:0ms
  • 内存:0kb
  • [2024-03-25 08:23:19]
  • 提交

answer

// #pragma GCC optimize("Ofast,no-stack-protector,unroll-loops",                  \
//                      "omit-frame-pointer", "inline")
// #pragma GCC target(                                                            \
//     "sse,sse2,sse3,ssse3,sse4,sse4.1,sse4.2,popcnt,abm,mmx,avx,avx2,fma,tune=native")
// #pragma GCC option("arch=native", "no-zero-upper") // Enable AVX

/// UH Top
#include <bits/stdc++.h>
#define db(x)   cerr << #x << ':' << (x) << '\n';
#define all(v)  (v).begin(), (v).end()
#define allr(v) (v).rbegin(), (v).rend()
// #define int ll
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
// typedef __int128_t int128;
typedef pair<ll, ll> pii;
typedef pair<ld, ll> pdi;
typedef pair<ld, ld> pdd;
typedef pair<ld, pdd> pdp;
typedef pair<string, ll> psi;
typedef pair<ll, string> pls;
typedef pair<string, string> pss;
typedef pair<ll, pii> pip;
typedef pair<pii, pii> ppp;
typedef complex<ld> point;
typedef vector<point> polygon;
typedef vector<ll> vi;
typedef pair<point, int> ppi;
#define prec(n)                                                                \
	cout.precision(n);                                                         \
	cout << fixed
const ll mod = (1e9 + 7);
const ld eps = (1e-9);
const ll oo = (ll)(1e9 + 5);
#define pi   acos(-1)
#define MAXN (ll)(1e6 + 5)

vector<string> gen() {
	vector<int> av;
	for (int i = 0; i < 8; i++)
		av.push_back(i);
	vector<pii> bb;
	for (int i = 0; i < 8; i += 2)
		for (int j = 1; j < 8; j += 2)
			bb.push_back(pii(i, j));

	vector<pip> rkr;
	for (int i = 0; i < 6; i++)
		for (int j = i + 1; j < 6; j++)
			for (int k = j + 1; k < 6; k++)
				rkr.push_back(pip(i, pii(j, k)));

	// cout << bb.size() << ' ' << rkr.size() << "\n";
	string sssss = "RKR";
	vector<string> rem = {"QNN", "NQN", "NNQ"};
	vector<string> ans;
	for (auto b : bb) {
		for (auto p : rkr) {
			vector<int> nav;
			string x(8, ' ');
			for (int i = 0; i < 8; i++) {
				if (i != b.first && i != b.second) {
					nav.push_back(i);
				} else {
					x[i] = 'B';
				}
			}
			// cout << nav.size() << "\n";
			// cout << p.first << ' ' << p.second.first << ' ' <<
			// p.second.second << "\n";
			vector<int> nnav;
			int cont = 0;
			for (int i = 0; i < 6; i++) {
				int pos = nav[i];
				// cout << nav[i] << "\n";
				if (i != p.first && i != p.second.first &&
				    i != p.second.second) {
					nnav.push_back(pos);
				} else {
					x[pos] = sssss[cont];
					cont++;
					// cout << pos << ' ' << cont << "\n";
				}
			}
			for (int j = 0; j < 3; j++) {
				for (int i = 0; i < 3; i++) {
					x[nnav[i]] = rem[j][i];
				}
				// cout << x << "\n";
				ans.push_back(x);
			}
			// break;
		}
		// break;
	}
	return ans;
}

int eqs[960][960];

int32_t main() {
	// ios_base::sync_with_stdio(0);
	// cin.tie(0);

	vector<string> ip = gen();
	// cout << ip.size() << "\n";
	int sz = 960;

	for (int i = 0; i < sz; i++)
		for (int j = 0; j < sz; j++)
			for (int k = 0; k < 8; k++)
				eqs[i][j] += (ip[i][k] == ip[j][k]);

	int best = 0;
	int cant = 960;
	for (int i = 0; i < 960; i++) {
		vector<int> f(9);
		for (int j = 0; j < 960; j++)
			f[eqs[i][j]]++;

		int ma = 0;
		for (int j = 0; j < 9; j++)
			ma = max(ma, f[j]);
		if (ma < cant) {
			cant = ma;
			best = i;
		}
	}

	// string xxxx = "RKRBBQNN";

	// for (int i = 0; i < 960; i++)
	// 	if (ip[i] == xxxx)
	// 		cout << "xxx: " << i << "\n";

	auto ask = [&](int i) {
		cout << ip[i] << "\n";
		cout.flush();
		int r = 0;
		cin >> r;
		// for (int j = 0; j < 8; j++)
		// 	r += (xxxx[j] == ip[i][j]);
		return r;
	};

	vector<int> precs[9];
	for (int i = 0; i < 960; i++)
		precs[eqs[best][i]].push_back(i);

	// cout << best << "\n";

	string s;
	cin >> s;
	while (s != "END") {
		int _;
		cin >> _;
		int cant = ask(best);
		vector<int> act = precs[cant];
		int cont = 0;
		while (cant != 8) {
			int best = 0;
			cant = 960;
			for (int i = 0; i < 960; i++) {
				vector<int> f(9);
				for (auto p : act)
					f[eqs[i][p]]++;
				int ma = 0;
				for (int j = 0; j < 9; j++)
					ma = max(ma, f[j]);
				if (ma < cant || (cant==ma && f[8]==1)) {
					cant = ma;
					best = i;
				}
			}

			vector<int> precs[9];
			for (auto i : act)
				precs[eqs[best][i]].push_back(i);

			cant = ask(best);
			act = precs[cant];
			// cout << cant << "\n";
			// cout << act.size() << "\n";
			// cont++;
			// for (auto i : act)
			// 	cout << i << ' ';
			// cout << "\n";
			// if (cont == 10)
			// 	break;
		}

		cin >> s;
		// s = "END";
	}

	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Time Limit Exceeded

input:

2 5

output:

NRBBNKQR
RKNNRQBB
QNRKBBRN
BBRKRQNN
BBRKRQNN
BBRKRQNN
BBRKRQNN
BBRKRQNN
BBRKRQNN
BBRKRQNN
BBRKRQNN
BBRKRQNN
BBRKRQNN
BBRKRQNN
BBRKRQNN
BBRKRQNN
BBRKRQNN
BBRKRQNN
BBRKRQNN
BBRKRQNN
BBRKRQNN
BBRKRQNN
BBRKRQNN
BBRKRQNN
BBRKRQNN
BBRKRQNN
BBRKRQNN
BBRKRQNN
BBRKRQNN
BBRKRQNN
BBRKRQNN
BBRKRQNN
BBRKRQNN
BBR...

result: