제출 #1166136

#제출 시각아이디문제언어결과실행 시간메모리
1166136thinknoexit메시지 (IOI24_message)C++20
0 / 100
170 ms844 KiB
#include "message.h"
#include<bits/stdc++.h>
using namespace std;
using ll = long long;

void send_message(vector<bool> M, vector<bool> C) {
    for (int i = 0;i < 31;i++) {
        vector<bool> A(31, C[i]);
        send_packet(A);
    }
    int n = M.size();
    {
        vector<bool> A(31, 0);
        int now = 0;
        for (int j = 0;j < 31;j++) {
            if (C[j] == 0) {
                A[j] = (n >> now) & 1;
                now++;
            }
        }
    }
    int now = 0;
    while (now < n) {
        vector<bool> A(31, 0);
        for (int j = 0;j < 31;j++) {
            if (C[j] == 0) {
                A[j] = M[now++];
                if (now == n) break;
            }
        }
        send_packet(A);
    }
}

vector<bool> receive_message(vector<vector<bool>> R) {
    vector<bool> ans;
    vector<bool> C(31, 0);
    for (int i = 0;i < 31;i++) {
        int cnt0 = 0, cnt1 = 0;
        for (bool x : R[i]) {
            if (x) cnt1++;
            else cnt0++;
        }
        C[i] = cnt1 > cnt0;
    }
    int n;
    {
        int now = 0;
        for (int j = 0;j < 31;j++) {
            if (C[j] == 0) {
                n += R[31][j] << now;
                now++;
            }
        }
    }
    for (int i = 32;i < (int)R.size();i++) {
        for (int j = 0;j < 31;j++) {
            if (C[j] == 0) {
                ans.push_back(R[i][j]);
                if ((int)ans.size() == n) break;
            }
        }
    }
    return ans;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...