제출 #118306

#제출 시각아이디문제언어결과실행 시간메모리
118306MAMBA앵무새 (IOI11_parrots)C++17
0 / 100
2068 ms16184 KiB
#include "encoder.h"
#include <bits/stdc++.h>
#include "encoderlib.h"


using namespace std;

#define rep(i, j, k) for (int i = j; i < (int)k; i++)
#define pb push_back
#define mt make_tuple
#define all(x) x.begin(), x.end()

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;

template <class T, class S>
inline bool smin(T &a, S b) {
  return (T)b < a ? a = b, 1 : 0;
}
template <class T, class S>
inline bool smax(T &a, S b) {
  return a < (T)b ? a = b, 1 : 0;
}

constexpr int N = 150 * 1000 + 10;

const int LEN = (1 << 10);

typedef bitset<LEN> sagy;

sagy operator+(sagy l, sagy r) {
  sagy res;
  bool cary = false;
  rep(i, 0, LEN) {
    int me = (cary ? 1 : 0) + (l[i] ? 1 : 0) + (r[i] ? 1 : 0);
    if (me & 1) res[i] = true;
    if (me > 1) cary = true;
  }
  return res;
}

bool operator<(sagy l, sagy r) {
  l ^= r;
  int id = -1;
  rep(i, 0, LEN) if (l[i]) id = i;
  return r[id];
}

const int L = 257;
const int R = L + 64 * 5;
sagy c[L][R];

inline void init() {
  rep(i, 0, R) {
    c[0][i][0] = true;
    if (i < L) c[i][i][0] = true;
    rep(j, 1, min(i, L)) c[j][i] = c[j - 1][i - 1] + c[j][i - 1];
  }
}

int cnt[L];

void encode(int N, int M[]) {
  init();
  return;
  sagy code;
  rep(i, 0, N) rep(j, 0, 8) code[(i << 3) + j] = (M[i] >> j) & 1;
  sagy ta_hala;
  int have = 5 * N;
  for (int i = 255; ~i; i--) {
    while (true) {
      sagy ta_alan = ta_hala;
      have--;
      cnt[i]++;
      ta_alan = ta_alan + c[i][have + i];
      if (code < ta_alan) {
        have++;
        cnt[i]--;
        break;
      }
      ta_hala = ta_alan;
    }
  }
  rep(i, 0, 256) rep(j, 0, cnt[i]) send(i);
}
#include "decoder.h"
#include <bits/stdc++.h>
#include "decoderlib.h"

using namespace std;

#define rep(i, j, k) for (int i = j; i < (int)k; i++)
#define pb push_back
#define mt make_tuple
#define all(x) x.begin(), x.end()

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;

template <class T, class S>
inline bool smin(T &a, S b) {
  return (T)b < a ? a = b, 1 : 0;
}
template <class T, class S>
inline bool smax(T &a, S b) {
  return a < (T)b ? a = b, 1 : 0;
}

constexpr int N = 150 * 1000 + 10;

const int LEN = (1 << 10);

typedef bitset<LEN> sagy;

sagy operator+(sagy l, sagy r) {
  sagy res;
  bool cary = false;
  rep(i, 0, LEN) {
    int me = (cary ? 1 : 0) + (l[i] ? 1 : 0) + (r[i] ? 1 : 0);
    if (me & 1) res[i] = true;
    if (me > 1) cary = true;
  }
  return res;
}

bool operator<(sagy l, sagy r) {
  l ^= r;
  int id = -1;
  rep(i, 0, LEN) if (l[i]) id = i;
  return r[id];
}

const int L = 257;
const int R = L + 64 * 5;
sagy c[L][R];

inline void init() {
  rep(i, 0, R) {
    c[0][i][0] = true;
    if (i < L) c[i][i][0] = true;
    rep(j, 1, min(i, L)) c[j][i] = c[j - 1][i - 1] + c[j][i - 1];
  }
}

int cnt[L];

void decode(int N, int L, int X[]) {
  return;
  init();
  rep(i, 0, L) cnt[X[i]]++;
  sagy code;
  int have = 5 * N;
  for (int i = 255; ~i; i--) {
    while (cnt[i] > 1) {
      code = code + c[i][have + i];
      have--;
      cnt[i]--;
    }
    have--;
  }
  code = code + c[0][0];
  rep(i, 0, N) {
    int res = 0;
    rep(j, 0, 8) if (code[(i << 3) + j]) res += (1 << j);
    output(res);
  }
}
#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...