Submission #1205638

#TimeUsernameProblemLanguageResultExecution timeMemory
1205638HappyCapybara메시지 (IOI24_message)C++20
10 / 100
414 ms868 KiB
#include "message.h"
#include<bits/stdc++.h>
using namespace std;

void send_message(vector<bool> M, vector<bool> C){
  vector<int> b;
  for (int i=0; i<31; i++){
    if (!C[i]) b.push_back(i);
  }
  for (int i=0; i<4; i++) send_packet(vector<bool>(31, (b[0]&(1<<i))));
  int s = M.size();
  int cur = 0;
  vector<vector<bool>> vb(29, vector<bool>(31, false));
  for (int i=1; i<=29; i++){
    vb[i-1][b[0]] = C[i];
    for (int j=1; j<16; j++){
      if (cur < s) vb[i-1][b[j]] = M[cur];
      else if (cur == s) vb[i-1][b[j]] = true;
      cur++;
    }
  }
  if (cur == s){
    vb.push_back(vector<bool>(31, false));
    vb.back()[b[0]] = 1;
  }
  while (cur < s){
    vb.push_back(vector<bool>(31, false));
    for (int i=0; i<16; i++){
      if (cur < s) vb.back()[b[i]] = M[cur];
      else if (cur == s) vb.back()[b[i]] = true;
      cur++;
    }
  }
  if (cur == s){
    vb.push_back(vector<bool>(31, false));
    vb.back()[b[0]] = 1;
  }
  for (vector<bool> x : vb) send_packet(x);
}

vector<bool> receive_message(vector<vector<bool>> R){
  vector<int> b = {0};
  for (int i=0; i<4; i++){
    int x = 0;
    for (int j=0; j<31; j++) x += R[i][j];
    if (x >= 16) b[0] |= (1<<i);
  }
  for (int i=1; i<=29; i++){
    if (!R[i+3][b[0]] && i != b[0]) b.push_back(i);
  }
  if (b.size() != 16) b.push_back(30);
  vector<bool> M;
  for (int i=4; i<R.size(); i++){
    for (int j=0; j<16; j++){
      if (j == 0 && i <= 32) continue;
      M.push_back(R[i][b[j]]);
    }
  }
  while (M.back() == false) M.pop_back();
  M.pop_back();
  return M;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...