Submission #1227061

#TimeUsernameProblemLanguageResultExecution timeMemory
1227061madlogic메시지 (IOI24_message)C++20
29.32 / 100
543 ms856 KiB
#include "message.h"

#include <bits/stdc++.h>
using namespace std;

constexpr int LEN = 31;

void send_message(std::vector<bool> M, std::vector<bool> C) {
    std::vector<bool> all_set(LEN);

    std::vector<int> idx;
    for (int i = 0; i < LEN; i++)
        if (!C[i]) {
            all_set[i] = true;
            idx.emplace_back(i);
        }

    for (int i = 0; i < LEN; i++)
        if (!C[i])
            send_packet(all_set);
        else
            send_packet(C);

    std::vector<bool> cur_packet(LEN);
    int l = 0;
    M.push_back(true);

    for (int i = 0; i < static_cast<int>(M.size()); i++) {
        if (l >= static_cast<int>(idx.size())) {
            send_packet(cur_packet);
            cur_packet = vector<bool>(LEN);
            l = 0;
        }

        cur_packet[idx[l++]] = M[i];
    }
    send_packet(cur_packet);
}

std::vector<bool> receive_message(std::vector<std::vector<bool>> R) {
    std::vector<int> idx;
    for (int i = 0; i < LEN; i++)
        if (count_if(begin(R[i]), end(R[i]), [&](int x) { return x; }) >= 16)
            idx.push_back(i);

    std::vector<bool> res;

    int l = 0, pos = LEN;
    while (pos < static_cast<int>(R.size())) {
        res.push_back(R[pos][idx[l++]]);
        if (l >= static_cast<int>(idx.size()))
            l = 0, ++pos;
    }

    while (!res.back())
        res.pop_back();
    res.pop_back();

    return res;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...