QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#559815#9237. Messagealexz12050 148ms4132kbC++172.7kb2024-09-12 09:31:192024-09-12 09:31:22

Judging History

This is the latest submission verdict.

  • [2024-09-12 09:31:22]
  • Judged
  • Verdict: 0
  • Time: 148ms
  • Memory: 4132kb
  • [2024-09-12 09:31:19]
  • Submitted

answer

#include <bits/stdc++.h>
#include "message.h"

using namespace std;

int arr[31];

const int LIM = 68;

namespace help{
	int message[31][LIM];
}

void send_message(std::vector<bool> M, std::vector<bool> C) {
	int p = -1;
	int f = -1;
	memset(arr, 0, sizeof(int) * 31);
	memset(help::message, -1, sizeof(int) * 31*LIM);
	for (int x = 0; x < 31; x ++){
		if (!C[x]){
			if (f == -1){
				p = x;
				f = x;
			}else {
				arr[p] = x-p;
				p = x;
			}
		}
	}
	arr[p] = 31+f - p;
	int c = 0;
	for (int x = 0; x < 31; x ++){
		if (!C[x]){
			for (int i = 0; i < arr[x]-1; i ++){
				help::message[x][i] = 0;	
			}
			help::message[x][arr[x]-1] = 1;
		}
	}
	int ind = 0;
	int pack = 0;
	for (int y = 0; y < LIM; y ++){
		for (int x = 0; x < 31; x ++){
			if (C[x]) continue;
			if (help::message[x][y] != -1){
				pack = y;
				continue;
			}
			if (ind < (int)M.size()){
				help::message[x][y] = M[ind++];
				pack = y;
			}else if (ind == (int)M.size()){
				help::message[x][y] = 1;
				ind ++;
			}else {
				help::message[x][y] = 0;
				ind ++;
			}
		}
	}
	pack ++;
	assert(ind >= (int)M.size());
	for (int y = 0; y < pack; y ++){
		std::vector<bool> res;
		for (int x = 0; x < 31; x ++){
			res.push_back((bool)help::message[x][y]);
		}
		send_packet(res);
	}
}

namespace check{

int good[31];
int time[31];

void dfs(int i, int t = 1){
	if (good[i] != 0){
		return;
	}
	if (time[i] != 0){
		if (t - time[i] == 16){
			good[i] = 1;
			dfs((arr[i] + i) % 31, t+1);
			return;
		}else {
			good[i] = -1;
			return;
		}
	}
	time[i] = t;
	dfs((arr[i] + i) % 31, t+1);
	if (good[i] == 0){
		good[i] = -1;
	}
}

}

std::vector<bool> receive_message(std::vector<std::vector<bool>> R) {
	memset(arr, 0, sizeof(int) * 31);
	memset(check::good, 0, sizeof(int) * 31);
	memset(help::message, -1, sizeof(int) * 31*LIM);
	memset(check::time, 0, sizeof(int) * 31);
	for (int y = 0; y < (int)R.size(); y ++){
		for (int x = 0; x < 31; x ++){
			help::message[x][y] = R[y][x];
		}
	}
	for (int x = 0; x < 31; x ++){
		for (int y = 0; y < R.size(); y ++){
			arr[x] ++;
			if (help::message[x][y] == 1){
				help::message[x][y] = -2;
				break;
			}
			help::message[x][y] = -2;
		}
	}

	for (int x = 0; x < 31; x ++){
		if (check::good[x] != 0){
			continue;
		}
		check::dfs(x);
	}

	int i = 0;
	std::vector<bool> res;
	for (int y = 0; y < (int)R.size(); y ++){
		for (int x = 0; x < 31; x ++){
			if (check::good[x] == 1){
				if (help::message[x][y] == -2){
					continue;
				}
				res.push_back(help::message[x][y]);
			}
		}
	}
	while (res.back() == 0){
		res.pop_back();
	}
	res.pop_back();

	return res;
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 10
Accepted
time: 29ms
memory: 3820kb

Manager to Aisha


Aisha to Manager


Manager to Basma


Basma to Manager


Manager to Checker

1

result:

points 1.0

Test #2:

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

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: 90
Accepted
time: 148ms
memory: 3772kb

Manager to Aisha


Aisha to Manager


Manager to Basma


Basma to Manager


Manager to Checker

1

result:

points 1.0

Test #9:

score: 0
Wrong Answer
time: 89ms
memory: 4132kb

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