제출 #1287535

#제출 시각아이디문제언어결과실행 시간메모리
1287535Namkhing메시지 (IOI24_message)C++20
66.34 / 100
439 ms840 KiB
#include "message.h"
#include <bits/stdc++.h>
using namespace std;

void send_message(std::vector<bool> M, std::vector<bool> C) {
    int pos = 0;
    for (int i = 0; i < 31; i++) {
        if (!C[i]) {
            pos = i;
            break;
        }
    }
    for (int i = 0; i < 5; i++) {
        bool x = (pos & (1 << i));
        send_packet(vector<bool>(31, x));
    }
    int need = 1035 - M.size() - 1;
    vector<bool> a(need, 0);
    a.push_back(1);
    for (bool x : M) {
        a.push_back(x);
    }
    vector<int> p;
    for (int i = 0; i < 31; i++) {
        if (!C[i] && i != pos) {
            p.push_back(i);
        } 
    }
    for (int i = 0, k = 0; i < 1035; i += 15, k++) {
        vector<bool> v(31);
        for (int j = 0; j < 15; j++) {
            v[p[j]] = a[i+j];
        }
        if (k < 31) {
            v[pos] = C[k];
        }
        send_packet(v);
    }
}

std::vector<bool> receive_message(std::vector<std::vector<bool>> R) {
    vector<bool> ans;
    int pos = 0;
    for (int i = 4; i >= 0; i--) {
        int sum = 0;
        for (bool x : R[i]) {
            sum += x;
        }
        pos = pos * 2 + (sum >= 16);
    }
    vector<int> p;
    for (int i = 5, k = 0; i < 36; i++, k++) {
        if (!R[i][pos] && k != pos) {
            p.push_back(k);
        }
    }
    bool flag = false;
    for (int i = 5; i < R.size(); i++) {
        for (int j = 0; j < 15; j++) {
            if (flag) {
                ans.push_back(R[i][p[j]]);
            }
            if (R[i][p[j]]) {
                flag = true;
            }
        }
    }
    return ans;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...