Submission #1189919

#TimeUsernameProblemLanguageResultExecution timeMemory
1189919SalihSahinMessage (IOI24_message)C++20
0 / 100
160 ms844 KiB
#include "bits/stdc++.h"
#define pb push_back
#include "message.h"
using namespace std;
#define ll long long

void send_message(vector<bool> M, vector<bool> C) {
  int N = M.size();

  vector<bool> A(31, 0), B(31, 1);
  for(int i = 0; i < 31; i++){
    if(C[i] == 0) send_packet(A);
    else send_packet(B);
  }

    vector<bool> dis_packet = A;
    int bt = 1;
    for(int j = 0; j < 31; j++){
       if(C[j] == 0){
          if(bt & N) dis_packet[j] = 1;
          bt *= 2;
       }
    }
    send_packet(dis_packet);

  for(int i = 0; i < N; i += 16){
    vector<bool> packet = A;
    int ind = 0;
    for(int j = 0; j < 31; j++){
        if(C[j] == 1) continue;
        if(i + ind < N) packet[j] = M[i + ind];
        ind++;
    }
  }
}

vector<bool> receive_message(vector<vector<bool>> R){
    int n = R.size();

    vector<int> C(31);
    for(int i = 0; i < 31; i++){
        int cnt = 0;
        for(auto itr: R[i]){
            cnt += itr;
        }
        if(cnt >= 16) C[i] = 1;
    }

    int len = 0, bt = 1;
    for(int i = 31; i <= 31; i++){
        for(int j = 0; j < 31; j++){
            if(C[j] == 0){
                if(R[i][j] == 1) len += bt;
                bt *= 2;
            }
        }
    }

    vector<bool> message;
    for(int i = 32; i < n; i++){
        for(int j = 0; j < 31; j++){
            if(C[j] == 0) message.pb(R[i][j]);
        }
    }
    while(message.size() > len) message.pop_back();

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