# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
13504 |
2015-02-22T02:44:02 Z |
ainta |
Parrots (IOI11_parrots) |
C++ |
|
237 ms |
41560 KB |
#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 |
1 |
Correct |
175 ms |
39920 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
179 ms |
40904 KB |
Output is correct |
2 |
Correct |
172 ms |
41056 KB |
Output is correct |
3 |
Correct |
177 ms |
41256 KB |
Output is correct |
4 |
Correct |
176 ms |
41296 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
177 ms |
41328 KB |
Output is correct |
2 |
Correct |
178 ms |
41328 KB |
Output is correct |
3 |
Correct |
181 ms |
41512 KB |
Output is correct |
4 |
Correct |
175 ms |
41512 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
176 ms |
41512 KB |
Output is correct |
2 |
Correct |
179 ms |
41512 KB |
Output is correct |
3 |
Correct |
179 ms |
41512 KB |
Output is correct |
4 |
Correct |
181 ms |
41512 KB |
Output is correct |
5 |
Correct |
184 ms |
41512 KB |
Output is correct |
6 |
Correct |
181 ms |
41536 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
176 ms |
41536 KB |
Output is correct - P = 1.750000 |
2 |
Correct |
184 ms |
41536 KB |
Output is correct - P = 2.437500 |
3 |
Correct |
179 ms |
41536 KB |
Output is correct - P = 2.484848 |
4 |
Correct |
185 ms |
41536 KB |
Output is correct - P = 3.300000 |
5 |
Correct |
184 ms |
41536 KB |
Output is correct - P = 3.850000 |
6 |
Correct |
237 ms |
41560 KB |
Output is correct - P = 4.031746 |
7 |
Correct |
185 ms |
41560 KB |
Output is correct - P = 4.093750 |