QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#885384 | #9237. Message | Geekmen | 0 | 216ms | 3840kb | C++17 | 1.9kb | 2025-02-06 15:29:18 | 2025-02-06 15:29:18 |
Judging History
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;
}
Details
Tip: Click on the bar to expand more detailed information
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