Submission #13486

# Submission time Handle Problem Language Result Execution time Memory
13486 2015-02-22T01:45:51 Z ainta Parrots (IOI11_parrots) C++
0 / 100
135 ms 79776 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++){
		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 (i = L - 1; i >= 0; i--){
		for (j = 0; j <= 70; j++)T[j] = M[j];
		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)break;
			for (j = 0; j < 70; j++){
				if (T[j] < 0)T[j + 1]--, T[j] += 256;
			}
			pv++;
		}
		for (j = 0; j <= 80; j++)M[j] = T[j];
		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++){
		P[0][k][0] = 1;
		for (i = 1; i <= L; i++){
			for (j = 0; j < 70; j++){
				T[j] += P[i - 1][k][j] * (255 + i);
				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;
			}
		}
	}
	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]);
}

Compilation message

encoder.cpp: In function 'void encode(int, int*)':
encoder.cpp:26: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 Runtime error 110 ms 39544 KB Execution killed with signal 11 (could be triggered by violating memory limits)
# Verdict Execution time Memory Grader output
1 Runtime error 135 ms 39636 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 95 ms 79272 KB Error : Bad encoded integer
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 88 ms 79272 KB Error : Bad encoded integer
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 95 ms 79272 KB Error : Bad encoded integer
2 Incorrect 92 ms 79432 KB Error : Bad encoded integer
3 Incorrect 93 ms 79560 KB Error : Bad encoded integer
4 Incorrect 100 ms 79560 KB Error : Bad encoded integer
5 Incorrect 106 ms 79776 KB Error : Bad encoded integer
6 Incorrect 109 ms 79776 KB Error : Bad encoded integer
7 Incorrect 109 ms 79776 KB Error : Bad encoded integer