QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#864573#5018. nthduongnc0000 29ms18824kbC++233.7kb2025-01-20 19:20:272025-01-20 19:20:29

Judging History

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

  • [2025-01-20 19:20:29]
  • 评测
  • 测评结果:0
  • 用时:29ms
  • 内存:18824kb
  • [2025-01-20 19:20:27]
  • 提交

answer

#include "nth.h"
#include <bits/stdc++.h>
#define taskname ""
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define i64 long long
#define isz(x) (int)x.size()
using namespace std;

#define lm (l + (r - l - 1) / 2)
#define rm (l + (r - l) / 2)
#define pl pfx
#define pr (pfx + (1 << (bit + 1)) - 1)

namespace Alice {
	vector<int> A;
	int l, r, c, bit = 20, pfx = 0, lst;

	int getlen() { return r - l; }

	int getvalue(int val) { return (val < pl ? pl : (val > pr ? pr : val)); }

	void initA(std::bitset<M> _A, unsigned S, unsigned _c) {
		c = _c - 1;
		// cout << "A: ";
		for (int i = 0; i < M; ++i) if (_A.test(i)) {
			// cout << i << " ";
			A.emplace_back(i);
		}
		// cout << endl;

		int cntA = isz(A), cntB = S - cntA;
		if (c < min(cntA, cntB)) {
			l = 0, r = c + 1, c = 0;
		}
		else if (cntA <= c and c < cntB) {
			A.insert(A.begin(), 0);
			l = 0, r = cntA + 1, c = 1;
		}
		else if (cntB <= c and c < cntA) {
			l = c - cntB, r = c + 1, c = 1;
		}
		else {
			l = c - cntB, r = cntA, c = 1;
		}

		if (r - l == 1) {
			for (int i = 20; i >= 0; --i) {
				sendA(A[l] >> i & 1);
			}
			return;
		}

		sendA(lst = (getvalue(A[lm]) >> bit & 1));
	}

	void receiveA(bool x) {
		// cout << "rA: " << x << endl;
		if (lst == x) {
			pfx += lst << bit;
			--bit;
		}
		else if (lst and not x) {
			r = lm + 1;
			// cout << "nA: " << l << " " << r << endl;
		}
		else {
			l = lm;
			// cout << "nA: " << l << " " << r << endl;
		}
		if (r - l == 2) {
			for (int i = l; i < r; ++i) for (int j = bit; j >= 0; --j) {
				// cout << "sendA: " << (getvalue(A[i]) >> j & 1) << endl;
				sendA(getvalue(A[i]) >> j & 1);
			}
			return;
		}
		sendA(lst = (getvalue(A[lm]) >> bit & 1));
	}
}

namespace Bob {
	vector<int> B, res;
	int l, r, c, bit = 20, pfx = 0, lst, cnt1 = 0, Aval = 0;

	int getlen() { return r - l; }

	int getvalue(int val) { return (val < pl ? pl : (val > pr ? pr : val)); }

	void initB(std::bitset<M> _B, unsigned S, unsigned _c) {
		c = _c - 1;
		// cout << "B: ";
		for (int i = 0; i < M; ++i) if (_B.test(i)) {
			// cout << i << " ";
			B.emplace_back(i);
		}
		// cout << endl;

		int cntB = isz(B), cntA = S - cntB;
		if (c < min(cntB, cntA)) {
			l = 0, r = c + 1, c = 0;
		}
		else if (cntB <= c and c < cntA) {
			B.insert(B.begin(), 0);
			l = 0, r = cntB + 1, c = 1;
		}
		else if (cntA <= c and c < cntB) {
			l = c - cntA, r = c + 1, c = 1;
		}
		else {
			l = c - cntA, r = cntB, c = 1;
		}

	}

	void receiveB(bool x) {
		if (r - l == 1) {
			Aval = Aval << 1 | ((int)x);
			if (++cnt1 == 21) {
				vector<int> res = {Aval, B[l]};
				sort(all(res)); report(res[c]);
			}
			return;
		}
		if (r - l == 2) {
			// cout << bit << endl;
			if (cnt1 == 0 or cnt1 == bit + 1) {
				res.emplace_back(0);
			}

			if (cnt1 < bit + 1) {
				res.back() = res.back() << 1 | ((int)x);
				++cnt1;
			}
			else {
				res.back() = res.back() << 1 | ((int)x);
				++cnt1;
			}

			// cout << isz(res) << endl;
			if (cnt1 == 2 * (bit + 1)) {
				res[0] += pfx, res[1] += pfx;
				res.emplace_back(getvalue(B[l]));
				res.emplace_back(getvalue(B[l + 1]));
				sort(all(res));
				// for (auto val : res) cout << val << " ";
				// cout << endl;
				res.pop_back(); res.erase(res.begin());
				report(res[c]);
			}
		}
		// cout << "rB: " << x << endl;
		sendB(lst = (getvalue(B[rm]) >> bit & 1));
		if (lst == x) {
			pfx += lst << bit;
			if (--bit == -1) report(pfx);
		}
		else if (lst and not x) {
			r = rm + 1;
			// cout << "nB: " << l << " " << r << endl;
		}
		else {
			l = rm;
			// cout << "nB: " << l << " " << r << endl;
		}
	}
}

詳細信息

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 100
Accepted
time: 29ms
memory: 18824kb

input:

000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

output:

3196614622 1083345 21

result:

points 1.0 OK L = 21

Test #2:

score: 100
Accepted
time: 29ms
memory: 13224kb

input:

111111100101001001100100000000111110101000101001001100101010011110000110101011010000000001000111000001011011110101010111001101010000101001101011101001110011001001101111110100001111001001010000110000011011000101010010000000011010010111110000111011011100110000100101111000111111110001100110110111101001...

output:

4153393124 307591 21

result:

points 1.0 OK L = 21

Test #3:

score: 0
Wrong Answer
time: 29ms
memory: 15372kb

input:

000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

output:

1444424234 522974 68

result:

wrong answer Wrong Answer.