QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#885384#9237. MessageGeekmen0 216ms3840kbC++171.9kb2025-02-06 15:29:182025-02-06 15:29:18

Judging History

This is the latest submission verdict.

  • [2025-02-06 15:29:18]
  • Judged
  • Verdict: 0
  • Time: 216ms
  • Memory: 3840kb
  • [2025-02-06 15:29:18]
  • Submitted

answer

#include <iostream>
#include <vector>
#include "message.h"
using namespace std;

void send_message(std::vector<bool> M, std::vector<bool> C) {
	int S = M.size();
	std::vector<int> pos;
	int sum = 0;
	for (int i = 0; i < 30; i ++) {
		// cout << "ok" << endl;
		if (!pos.size()) {
			send_packet(vector<bool>(31, C[i]));
			if (!C[i]) pos.push_back(i);
			else sum ++;
		}
		else {
			std::vector<bool> tmp(31);
			int L = pos.size(), j;
			for (j = 0; j < L && i + j < 30; j ++) {
				tmp[pos[j]] = C[i + j];
				if (!C[i + j]) pos.push_back(i + j);
				else sum ++;
			}
			send_packet(tmp), i = i + j - 1;
		}
		if (sum == 15) {
			for (int j = i; j < 30; j ++)
				if (!C[j]) pos.push_back(j);
			break;
		}
	}
	if (!C[30]) pos.push_back(30);

	std::vector<bool> len(31);
	for (int i = 0; i < 16; i ++)
		len[pos[i]] = S >> i & 1;

	send_packet(len);
	for (int i = 0; i < S; i += 16) {
		std::vector<bool> tmp(31);
		for (int j = i; j < min(i + 16, S); j ++)
			tmp[pos[j - i]] = M[j];
		send_packet(tmp);
	}
}
std::vector<bool> receive_message(std::vector<vector<bool>> R) {
	// cout << "OK" << endl;
	std::vector<int> pos;
	int sum = 0, pt = 0, i;
	for (i = 0; i < R.size(); i ++) {
		if (pt == 30) break;
		if (sum == 15) {
			for (int j = pt; j < 30; j ++)
				pos.push_back(j);
			break;
		}
		if (!pos.size()) {
			int C[2] = {0};
			for (int j = 0; j < 31; j ++)
				C[R[i][j]] ++;
			if (C[0] > C[1]) pos.push_back(i);
			sum += C[1] > C[0], pt ++;
		} else {
			int L = pos.size(), j;
			for (j = 0; j < L && pt + j < 30; j ++)
				if (!R[i][pos[j]])
					pos.push_back(pt + j);
				else sum ++;
			pt += j;
		}
	}
	if (sum == 15) pos.push_back(30);

	int S = 0;
	for (int j = 0; j < 16; j ++)
		S |= (R[i][pos[j]] << j);
	i ++;

	std::vector<bool> res;
	for (; i < R.size(); i ++)
		for (auto j : pos)
			res.push_back(R[i][j]);
	while (res.size() > S) res.pop_back();

	return res;
}

详细

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 0
Wrong Answer
time: 30ms
memory: 3840kb

Manager to Aisha


Aisha to Manager


Manager to Basma


Basma to Manager


Manager to Checker

0
ing with message 'decoded message is incorrect'
Sending secret with code DIE to mgr2sol[1]
Quitting with result code 1

result:

wrong output format Extra information in the output file

Subtask #2:

score: 0
Wrong Answer

Test #8:

score: 0
Wrong Answer
time: 216ms
memory: 3840kb

Manager to Aisha


Aisha to Manager


Manager to Basma


Basma to Manager


Manager to Checker

0
ing with message 'decoded message is incorrect'
Sending secret with code DIE to mgr2sol[1]
Quitting with result code 1

result:

wrong output format Extra information in the output file