Submission #118316

#TimeUsernameProblemLanguageResultExecution timeMemory
118316MAMBAParrots (IOI11_parrots)C++17
0 / 100
379 ms262144 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++) typedef long long ll; constexpr int N = 150 * 1000 + 10; const int LEN = 600; typedef array<int, LEN> sagy; sagy operator+(sagy l, sagy r) { sagy res; bool cary = false; rep(i, 0, LEN) { ll tmp = 1ll * l[i] + r[i] + (cary ? 1 : 0); res[i] = tmp & ((1l << 32) - 1); cary = tmp >> 32; } return res; } bool operator<(sagy l, sagy r) { for (int i = LEN - 1; ~i; i--) { int tmp = l[i] ^ r[i]; if (tmp) { for (int j = 31;; j--) { if ((tmp >> j) & 1) return (r[i] >> j) & 1; } } } return false; } 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(); 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++) typedef long long ll; constexpr int N = 150 * 1000 + 10; const int LEN = 600; typedef array<int, LEN> sagy; sagy operator+(sagy l, sagy r) { sagy res; bool cary = false; rep(i, 0, LEN) { ll tmp = 1ll * l[i] + r[i] + (cary ? 1 : 0); res[i] = tmp & ((1l << 32) - 1); cary = tmp >> 32; } return res; } bool operator<(sagy l, sagy r) { for (int i = LEN - 1; ~i; i--) { int tmp = l[i] ^ r[i]; if (tmp) { for (int j = 31;; j--) { if ((tmp >> j) & 1) return (r[i] >> j) & 1; } } } return false; } 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[]) { 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...