This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "encoder.h"
#include "encoderlib.h"
static int P[271][257][72], T[300];
void encode(int N, int M[])
{
int i, j, L, ck, k;
for (k = 1; k <= 256; k++){
if (P[0][k][0])break;
P[0][k][0] = 1;
for (i = 1; i < 270; i++){
for (j = 0; j < 70; j++){
T[j] += P[i - 1][k][j] * (k + i - 1);
T[j + 1] += T[j] >> 8;
T[j] &= 255;
}
for (j = 70; j >= 0; j--){
if (T[j] % i){
T[j - 1] += ((T[j] % i) << 8);
}
T[j] /= i;
}
for (j = 0; j <= 70; j++){
P[i][k][j] = T[j];
T[j] = 0;
}
}
if (i != 270)break;
}
for (i = 1; i < 270; i++){
for (j = 70; j >= 0; j--)if (P[i][256][j])break;
if (j >= N)break;
}
L = i;
int pv = 0;
for (j = 0; j < N; j++)T[j] = M[j];
for (i = L - 1; i >= 0; i--){
while (1){
ck = 0;
for (j = 70; j >= 0; j--){
if (!ck && T[j] - P[i][256-pv][j] != 0){
if (T[j] < P[i][256-pv][j])break;
ck = 1;
}
T[j] -= P[i][256-pv][j];
}
if (j != -1){
for (j = j + 1; j <= 70; j++)T[j] += P[i][256 - pv][j];
break;
}
for (j = 0; j < 70; j++){
if (T[j] < 0)T[j + 1]--, T[j] += 256;
}
pv++;
}
send(pv);
}
}
#include "decoder.h"
#include "decoderlib.h"
#include<stdio.h>
#include<algorithm>
using namespace std;
static int P[271][257][72], T[300], Res[300];
void decode(int N, int L, int X[])
{
sort(X, X + L);
int i, j, k, pv = 0;
for (k = 1; k <= 256; k++){
if (P[0][k][0])break;
P[0][k][0] = 1;
for (i = 1; i < 270; i++){
for (j = 0; j < 70; j++){
T[j] += P[i - 1][k][j] * (k + i - 1);
T[j + 1] += T[j] >> 8;
T[j] &= 255;
}
for (j = 70; j >= 0; j--){
if (T[j] % i){
T[j - 1] += ((T[j] % i) << 8);
}
T[j] /= i;
}
for (j = 0; j <= 70; j++){
P[i][k][j] = T[j];
T[j] = 0;
}
}
}
for (i = 0; i < L; i++){
while (pv < X[i]){
for (j = 0; j <= 70; j++){
Res[j] += P[L - i - 1][256 - pv][j];
}
pv++;
}
}
for (i = 0; i <= 70; i++){
Res[i + 1] += (Res[i] >> 8);
Res[i] &= 255;
}
for (i = 0; i < N; i++){
output(Res[i]);
Res[i] = 0;
}
}
# | 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... |