이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
#include "encoder.h"
#include "encoderlib.h"
using namespace std;
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define all(vr) vr.begin(),vr.end()
#define vi vector<int>
#define vll vector<ll>
const int N = 1e5 + 10;
ll C[42][42];
void build()
{
for (int i = 0; i <= 40; ++i)
{
C[0][i] = 1;
for (int j = 2 ; j <= i; ++j) C[j][i] = C[j - 1][i - 1] + C[j][i - 1];
}
}
vi find_kth(ll k, int d)
{
vi ans;
int s = d * 5;
for (int i = 0 ; i < 16; ++i)
{
ll sl = C[15 - i][s + 15 - i];
while (k >= sl) k -= sl, s--, ans.eb(i);
}
return ans;
}
void encode(int n, int M[])
{
build();
for (int i = 0; i < n; i += 4)
{
ll s = 0;
int d = 0;
for (int j = i; j < min(n, i + 4); ++j) d++, s = (s << 8) + M[j];
vi vt = find_kth(s, d);
for (int x : vt) send((x << 4) + (i / 4));
}
}
#include<bits/stdc++.h>
#include "decoder.h"
#include "decoderlib.h"
using namespace std;
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define all(vr) vr.begin(),vr.end()
#define vi vector<int>
#define vll vector<ll>
const int N = 1e5 + 10;
ll C[42][42];
void build()
{
for (int i = 0; i <= 40; ++i)
{
C[0][i] = 1;
for (int j = 2 ; j <= i; ++j) C[j][i] = C[j - 1][i - 1] + C[j][i - 1];
}
}
int a[20][20];
ll find_order(int cnt[], int d)
{
ll k = 0;
int s = d * 5;
for (int i = 0 ; i < 16; ++i)
{
ll sl = C[15 - i][s + 15 - i];
for (int j = 0 ; j < cnt[i]; ++j) k += sl, s--;
}
return k;
}
void decode(int n, int L, int X[])
{
build();
for (int i = 0; i < 16; ++i)
for (int j = 0; j < 16; ++j) a[i][j] = 0;
for (int i = 0; i < L; ++i) a[X[i] & 15][X[i] >> 4]++;
for (int i = 0; i < n; i += 4)
{
int d = min(4, n - i), id = i / 4;
ll k = find_order(a[id], d);
vi vt;
for (int j = 0; j < d; ++j) vt.eb(k & 255), k >>= 8;
reverse(all(vt));
for (int x : vt) output(x);
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |