Submission #1242654

#TimeUsernameProblemLanguageResultExecution timeMemory
1242654fskaricaMessage (IOI24_message)C++20
0 / 100
130 ms844 KiB
#include <bits/stdc++.h>
//#include "message.h"

using namespace std;

#define ll long long
#define fi first
#define se second
#define pii pair<int, int>

vector <vector<bool>> v = {{1, 0, 0, 1, 0, 0, 1, 1, 0, 1, 0, 1, 1, 1, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 1, 1, 0, 1, 0, 0}, {1, 1, 1, 1, 1, 0, 1, 0, 1, 1, 0, 1, 1, 1, 0, 1, 0, 1, 1, 0, 0, 0, 1, 1, 1, 0, 1, 0, 0, 1, 0}, {0, 0, 1, 1, 0, 0, 1, 0, 0, 0, 0, 1, 1, 0, 1, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0, 1, 1, 1, 1, 1, 1}, {1, 1, 1, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 1, 1, 0, 1, 0, 0, 0}, {1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 1, 0, 1, 1, 0, 0, 0, 0, 0, 1, 1, 0, 1, 1, 1, 1, 0, 0}, {1, 1, 0, 1, 1, 0, 0, 1, 1, 1, 0, 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0}, {0, 0, 0, 0, 0, 1, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1}, {1, 0, 1, 1, 1, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 1, 0, 1, 1, 0, 0, 0, 0, 1, 0, 0}, {1, 0, 1, 0, 0, 0, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 1, 1}, {0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 0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;
//std::vector<bool> send_packet(std::vector<bool> A) {
//    srand(time(0));
//    vector <bool> ret = A;
//
//    for (int i = 0; i < 31; i++) {
//        if (!cc[i]) continue;
//
//        ret[i] = rand() % 2;
//    }
//
//    bla.push_back(ret);
//    return ret;
//}

std::vector<bool> send_packet(std::vector<bool> A);

void send_message(std::vector<bool> M, std::vector<bool> C) {
    cc = C;

    vector <bool> zero, one;

    for (auto e : v) send_packet(e);

    int n = M.size();
    vector <bool> sz(31, 0);
    for (int i = 30; i >= 0; i--) {
        if (C[i]) continue;

        if (n % 2) sz[i] = 1;
        n /= 2;
    }
    send_packet(sz); /// this sends how long is M

    int pos = 0;
    vector <bool> msg(31, 0);
    for (auto e : M) {
        while (pos < 31 && C[pos]) pos++;
        if (pos == 31) {
            pos = 0;
            send_packet(msg);
            for (int i = 0; i < 31; i++) msg[i] = 0;
        }
        while (pos < 31 && C[pos]) pos++;

        if (e) msg[pos] = 1;
        pos++;
    }

    if (pos != 0) send_packet(msg);
}

std::vector<bool> receive_message(std::vector<std::vector<bool>> R) {
    vector <int> C(31, 0);

    for (int i = 0; i < v.size(); i++) {
        for (int j = 0; j < 31; j++) {
            if (v[i][j] != R[i][j]) C[j] = 1;
        }
    }

//    cout << "C -> "; for (int i = 0; i < 31; i++) cout << C[i] << " "; cout << "\n";

    int sz = 0;
    int cnt = 0;
    for (int i = 30; i >= 0; i--) {
        if (C[i]) continue;
        sz += R[v.size()][i] * (1 << cnt);
        cnt++;
    }

    vector <bool> ret;
    cnt = 0;
    for (int i = v.size() + 1; i < R.size(); i++) {
        for (int j = 0; j < 31; j++) {
            if (cnt == sz) continue;
            if (C[j]) continue;

            int x = R[i][j];
            ret.push_back(x);
            cnt++;
        }
    }

    return ret;
}

//int main() {
////    srand(time(0));
////    for (int i = 0; i < 1234523; i++) rand();
////
////    v.clear();
////    for (int i = 0; i < 20; i++) {
////        vector <bool> rah;
////        for (int j = 0; j < 31; j++) rah.push_back(rand() % 2);
////        v.push_back(rah);
////    }
////
////    cout << "vector <vector<bool>> v = {";
////    for (auto e : v) {
////        cout << "{";
////        for (int i = 0; i < 31; i++) {
////            cout << e[i];
////            if (i != 30) cout << ", ";
////        }
////        if (e != v.back()) cout << "}, ";
////    }
////    cout << "}};";
////
////    return 0;
//
//    send_message({0, 0, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0}, {0, 1, 1, 0, 1, 1, 1, 0, 0, 0, 0, 1, 0, 1, 1, 0, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 1, 1, 0, 1});
////    cout << bla.size() << " bla size\n\n";
//
//    vector <bool> sol = receive_message(bla);
//    cout << "sol - "; for (auto e : sol) cout << e << " "; cout << "\n";
//}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...