제출 #1287512

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

void send_message(std::vector<bool> M, std::vector<bool> C) {
    vector<int> pos;
    for (int i = 0; i < 30; i++) {
        send_packet(vector<bool>(31, C[i]));
        if (!C[i]) {
            pos.push_back(i);
        }
    }
    if (pos.size() == 15) {
        pos.push_back(30);
    }
    M.insert(M.begin(), true);
    while (M.size() < 1040) {
        M.insert(M.begin(), false);
    }
    for (int i = 0; i < 1040; i += 16) {
        vector<bool> v(31);
        for (int j = i; j < i + 16; j++) {
            v[pos[j-i]] = M[j];
        }
        send_packet(v);
    }
}

std::vector<bool> receive_message(std::vector<std::vector<bool>> R) {
    vector<bool> ans;
    vector<int> pos;
    for (int i = 0; i < 30; i++) {
        int cnt = 0;
        for (bool x : R[i]) {
            cnt += x;
        }
        if (cnt < 16) {
            pos.push_back(i);
        }
    }
    if (pos.size() == 15) {
        pos.push_back(30);
    }
    bool flag = false;
    for (int i = 30; i < R.size(); i++) {
        for (int j = 0; j < 16; j++) {
            if (flag) {
                ans.push_back(R[i][pos[j]]);
            }
            if (R[i][pos[j]]) {
                flag = true;
            }
        }
    }
    return ans;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...