QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#557467 | #9237. Message | alexz1205 | 0 | 54ms | 4072kb | C++17 | 3.5kb | 2024-09-11 09:51:26 | 2024-09-11 09:51:27 |
Judging History
answer
#include <bits/stdc++.h>
#include "message.h"
using namespace std;
int arr[31];
namespace help{
int message[31][66];
}
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*66);
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;
for (int x = 0; x < 31; x ++){
if (!C[x]){
// do elias omega coding
std::vector<int> res;
res.push_back(0);
int v = arr[x];
while (v != 1){
res.push_back(v);
v = 31-__builtin_clz(v);
}
reverse(res.begin(), res.end());
int ind = 0;
for (int v: res){
if (v == 0){
help::message[x][ind++] = 0;
}else {
for (int i = 31-__builtin_clz(v); i >= 0; i --){
help::message[x][ind++] = (v & (1 << i)) > 0;
}
}
}
}
}
std::vector<std::array<int, 2>> sizeW;
int ind = 0;
int pack = 0;
for (int y = 0; y < 66; y ++){
for (int x = 0; x < 31; x ++){
if (C[x]) continue;
if (help::message[x][y] != -1){
pack = x;
continue;
}
if (sizeW.size() < 10){
sizeW.push_back({x, y});
help::message[x][y] = -2;
}else if (ind < (int)M.size()){
help::message[x][y] = M[ind++];
pack = x;
}
}
}
assert(ind == (int)M.size());
for (int x = 0; x < 10; x ++){
help::message[sizeW[x][0]][sizeW[x][1]] = (bool)((M.size()-1) & (1 << x));
}
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);
}
}
int decodeElias(int i){
int N = 1;
int ind = 0;
while (help::message[i][ind] != 0){
int v = 0;
for (int x = 0; x <= N; x ++){
int val = help::message[i][ind];
help::message[i][ind ++] = -2;
v <<= 1;
v += val;
//v += val << x;
}
N = v;
if (ind >= 12){
return 0;
}
}
help::message[i][ind ++] = -2;
return N;
}
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*66);
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 ++){
arr[x] = decodeElias(x);
}
for (int x = 0; x < 31; x ++){
if (check::good[x] != 0){
continue;
}
check::dfs(x);
}
for (int x = 0; x < 31; x ++){
cout << (check::good[x] == 1) << " ";
}
cout << endl;
int totLen = 0;
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;
}
if (i < 10){
totLen += (int)help::message[x][y] << (i ++);
}else {
if (res.empty()){
totLen ++;
}
if ((int)res.size() < totLen){
res.push_back(help::message[x][y]);
}
}
}
}
}
return res;
}
詳細信息
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 0
Wrong Answer
time: 54ms
memory: 4072kb
Manager to Aisha
Aisha to Manager
Manager to Basma
Basma to Manager
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Manager to Checker
0 ing with message 'Possible tampering with sol2mgr[1]' Sending secret with code DIE to mgr2sol[1] Quitting with result code 11
result:
wrong output format Extra information in the output file
Subtask #2:
score: 0
Instance #0 Runtime Error
Test #8:
score: 0
Instance #0 Runtime Error
Manager to Aisha
Aisha to Manager
Manager to Basma
Basma to Manager
Manager to Checker
0 ing with message 'manual RTE, cant read int from grader' Sending secret with code DIE to mgr2sol[1] Quitting with result code 1