Submission #1244285

#TimeUsernameProblemLanguageResultExecution timeMemory
1244285tamyteParrots (IOI11_parrots)C++17
52 / 100
4 ms840 KiB
#include "encoder.h"
#include "encoderlib.h"
#include <bits/stdc++.h>
using namespace std;


void dbg(int n) {
  for (int i = 0; i < 8; ++i) {
    cout << (n >> i & 1);
  }
  cout << endl;
}

void encode(int N, int M[])
{
  for (int i = 0; i < N; ++i) {
      int msg = 0;
      for (int j = 0; j < 4; ++j) {
        if (i >> j & 1) {
          msg += 1 << j;
        }
      }
      for (int j = 0; j < 8; ++j) {
          int now = msg;
          for (int k = 0; k < 3; ++k) {
            if (j >> k & 1) {
              now += (1 << (k + 4));
            }
          }
          now += (1 << 7) * (M[i] >> j & 1);
          // dbg(now);
          send(now);

      }
  }
}
#include "decoder.h"
#include "decoderlib.h"
#include <bits/stdc++.h>
using namespace std;



void decode(int N, int L, int X[])
{
  vector<int> res(N);
  for (int i = 0; i < L; ++i) {
    int index = 0;
    for (int j = 0; j < 4; ++j) {
      if (X[i] >> j & 1) {
        index += (1 << j);
      }
    }
    int bit = 0;
    for (int j = 4; j < 7; ++j) {
      if (X[i] >> j & 1) {
        bit += (1 << (j - 4));
      }
    }
    int state = (X[i] >> 7 & 1);
    res[index] += state * (1 << bit);
  }
  for (int i = 0; i < N; ++i) {
    output(res[i]);
  }
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...