Submission #13503

# Submission time Handle Problem Language Result Execution time Memory
13503 2015-02-22T02:42:32 Z ainta Parrots (IOI11_parrots) C++
0 / 100
183 ms 41512 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++){
				if (T[j])L = j;
				P[i][k][j] = T[j];
				T[j] = 0;
			}
			if (k == 256 && L >= N)break;
		}
		if (i != 270)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;
	}
}

Compilation message

encoder.cpp: In function 'void encode(int, int*)':
encoder.cpp:27:22: warning: 'L' may be used uninitialized in this function [-Wmaybe-uninitialized]
    if (k == 256 && L >= N)break;
                    ~~^~~~
# Verdict Execution time Memory Grader output
1 Incorrect 87 ms 39848 KB Error : Encoded message too long
# Verdict Execution time Memory Grader output
1 Incorrect 95 ms 40360 KB Error : Encoded message too long
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 93 ms 40360 KB Error : Encoded message too long
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 90 ms 40360 KB Error : Encoded message too long
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 86 ms 40360 KB Error : Encoded message too long
2 Incorrect 178 ms 41064 KB Error : Output is wrong
3 Incorrect 182 ms 41408 KB Error : Output is wrong
4 Incorrect 183 ms 41408 KB Error : Output is wrong
5 Incorrect 182 ms 41408 KB Error : Output is wrong
6 Incorrect 183 ms 41512 KB Error : Output is wrong
7 Incorrect 183 ms 41512 KB Error : Output is wrong