QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#594127#9237. MessageDecember4560 45ms4008kbC++174.0kb2024-09-27 19:33:512024-09-27 19:33:51

Judging History

This is the latest submission verdict.

  • [2024-09-27 19:33:51]
  • Judged
  • Verdict: 0
  • Time: 45ms
  • Memory: 4008kb
  • [2024-09-27 19:33:51]
  • Submitted

answer

#include "message.h"

void send_message(std::vector<bool> M, std::vector<bool> C) {
    std::vector<int> A;
    std::vector<bool> P(31);

    int cnt1 = 0, cnt2 = 0;

    for (int i = 0; i < 30; cnt1 ++) {
        if (!A.size()) {
            if (!C[i]) {
                A.push_back(i);
            }
            i ++;
            continue;
        }
        for (int j = 0; i < 30 && j < A.size(); i ++, j ++) {
            if (!(P[A[j]] = C[i])) {
                A.push_back(i);
            }
        }
    }
    A.clear();

    for (int i = 29; i >= 0; cnt2 ++) {
        if (!A.size()) {
            if (!C[i]) {
                A.push_back(i);
            }
            i --;
            continue;
        }
        for (int j = 0; i >= 0 && j < A.size(); i --, j ++) {
            if (!(P[A[j]] = C[i])) {
                A.push_back(i);
            }
        }
    }
    A.clear();

    if (cnt1 < cnt2) {
        send_packet(std::vector<bool>(31, 0));
        for (int i = 0; i < 30;) {
            if (!A.size()) {
                if (!C[i]) {
                    A.push_back(i);
                }
                send_packet(std::vector<bool>(31, C[i ++]));
                continue;
            }
            for (int j = 0; i < 30 && j < A.size(); i ++, j ++) {
                if (!(P[A[j]] = C[i])) {
                    A.push_back(i);
                }
            }
            send_packet(P);
        }
    } else {
        for (int i = 29; i >= 0;) {
            if (!A.size()) {
                if (!C[i]) {
                    A.push_back(i);
                }
                send_packet(std::vector<bool>(31, C[i --]));
                continue;
            }
            for (int j = 0; i >= 0 && j < A.size(); i --, j ++) {
                if (!(P[A[j]] = C[i])) {
                    A.push_back(i);
                }
            }
            send_packet(P);
        }
    }

    if (!C[30]) {
        A.push_back(30);
    }

    for (int i = 0; i < 4; i ++) {
        P[A[i]] = M.size() >> i & 1;
    }
    send_packet(P);

    for (int i = 0; i < M.size(); i += 16) {
        for (int j = i; j < i + 16 && j < M.size(); j ++) {
            P[A[j - i]] = M[j];
        }
        send_packet(P);
    }
}

std::vector<bool> receive_message(std::vector<std::vector<bool>> R) {
    std::vector<bool> M, C;
    std::vector<int> A;

    int cur = 1, cnt = 0;
    for (int x : R[0]) {
        cnt += x;
    }

    if (cnt << 1 < 31) {
        for (int i = 0; i < 30; cur ++) {
            if (!A.size()) {
                cnt = 0;
                for (int x : R[cur]) {
                    cnt += x;
                }
                if (cnt << 1 < 31) {
                    A.push_back(i);
                }
                i ++;
                continue;
            }

            for (int j = 0; i < 30 && j < A.size(); i ++, j ++) {
                if (!R[cur][A[j]]) {
                    A.push_back(i);
                }
            }
        }
    } else {
        for (int i = 29; i >= 0; cur ++) {
            if (!A.size()) {
                cnt = 0;
                for (int x : R[cur]) {
                    cnt += x;
                }
                if (cnt << 1 < 31) {
                    A.push_back(i);
                }
                i --;
                continue;
            }

            for (int j = 0; i >= 0 && j < A.size(); i --, j ++) {
                if (!R[cur][A[j]]) {
                    A.push_back(i);
                }
            }
        }
    }

    if (A.size() < 16) {
        A.push_back(30);
    }

    int res = 0;
    for (int i = 0; i < 4; i ++) {
        res |= R[cur][A[i]] << i;
    }
    if (!res) {
        res = 16;
    }

    for (int i = cur + 1; i + 1 < R.size(); i ++) {
        for (int j = 0; j < 16; j ++) {
            M.push_back(R[i][A[j]]);
        }
    }
    for (int i = 0; i < res; i ++) {
        M.push_back(R.back()[A[i]]);
    }

    return M;
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 0
Wrong Answer
time: 45ms
memory: 4008kb

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
Instance #1 Runtime Error

Test #8:

score: 0
Instance #1 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'
Quitting with result code 1

result: