제출 #1202086

#제출 시각아이디문제언어결과실행 시간메모리
1202086tralalero_tralala앵무새 (IOI11_parrots)C++20
100 / 100
9 ms840 KiB
#include "encoder.h"
#include "encoderlib.h"
#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define fore(i,a,b) for(lli i = (a), abcdxd = (b); i < abcdxd; i++)
#define f first
#define s second
#define ENDL '\n'
#define pb push_back
#define sz(s) lli((s).size())
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
using namespace std;
typedef long long lli;
// typedef long long LLI;
typedef pair<lli,lli> ii;
typedef vector<lli> vi;
typedef vector<ii> vii;
typedef long double ld;
#define deb(x) cout << #x << ": " << x << endl;
#define BIGLLI __int128
typedef vector<vi> mtrx;

const lli N = 5;
const lli M = 25;
const lli G = 19;
const lli B = 256;

lli ct = 0;

lli fpow(lli x, lli y){
  lli r = 1;
  while (y){
    if (y&1) r = (r * x);
    x = (x * x);
    y>>=1;
  }
  return r;
}

lli calcF(lli a, lli b){
  if (a > b) swap(a, b);
  __int128 r = 1;
  for (__int128 i = a+b; i >= 1; i--){
    if (i > b) r *= i;
    if (i <= a) r /= i;
  }
  return lli(r);
}

void convert(lli cc, lli sho){
  sho = 5 * sho;
  // deb(cc);
  lli lm = ct + G;
  for (lli id = 0; id < sho; id++){
    while (calcF(lm - ct, sho - id - 1) <= cc){
      cc -= calcF(lm - ct, sho - id - 1);
      ct++;
    }
    send(ct);
    // deb(ct);
    // deb(id);
  }
}

void encode(int n, int v[])
{
  // cout << "ini" << endl;
  ct = 0;
  for(lli I = 0; I < n; I += 5){
    lli cc = 0, che = min(5ll, n - I);
    fore(i,0,che) cc += v[I+i] * (fpow(256, che - i - 1));
    convert(cc, che);
  }
}
#include "decoder.h"
#include "decoderlib.h"
#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define fore(i,a,b) for(lli i = (a), abcdxd = (b); i < abcdxd; i++)
#define f first
#define s second
#define ENDL '\n'
#define pb push_back
#define sz(s) lli((s).size())
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
using namespace std;
typedef long long lli;
// typedef long long LLI;
typedef pair<lli,lli> ii;
typedef vector<lli> vi;
typedef vector<ii> vii;
typedef long double ld;
#define deb(x) cout << #x << ": " << x << endl;
#define BIGLLI __int128
typedef vector<vi> mtrx;

// const lli N = 5;
// const lli M = 25;
// const lli G = 19;
// const lli B = 256;

lli ch = 0;

lli fepow(lli x, lli y){
  lli r = 1;
  while (y){
    if (y&1) r = (r * x);
    x = (x * x);
    y>>=1;
  }
  return r;
}

lli calcA(lli a, lli b){
  if (a > b) swap(a, b);
  __int128 r = 1;
  for (__int128 i = a+b; i >= 1; i--){
    if (i > b) r *= i;
    if (i <= a) r /= i;
  }
  return lli(r);
}

void decode(int L, int n, int V[])
{
  ch = 0;
  vi v(n); fore(i,0,n) v[i] = V[i];
  sort(all(v));
  for(lli I = 0; I < n; I+=25){
    lli sho = min(n - I, 25ll);
    lli cc = 0, lm = ch + 19;
    fore(i,0,sho) while (ch < v[I+i]){
      cc += calcA(lm - ch, sho - i - 1);
      ch++;
    }
    lli cha = sho/5;
    // cout << sho << ' ' << cha << endl;
    fore(i,0,cha){
      lli yy = 0;
      while (fepow(256, cha - i - 1) <= cc) cc -= fepow(256, cha - i - 1), yy++;
      if (L > 0) output(yy);
      L--;
      // deb(yy);
    }
  }
}
#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...