Submission #981

# Submission time Handle Problem Language Result Execution time Memory
981 2013-06-06T15:46:37 Z tncks0121 Parrots (IOI11_parrots) C++
98 / 100
12 ms 2528 KB
#include "encoder.h"
#include "encoderlib.h"

int count[1000];

void encode (int N, int M[]) { // 6N approach
	int c1 = 0, c0 = 0;
	for(int i = 0; i < N; i++) {
		for(int j = 0; j < 4; j++) {
			count[i*4+j] = !!(M[i] & 1<<(j*2+1))*2 + !!(M[i] & 1<<(j*2));
			c1 += count[i*4+j];
		}
	}
	c0 = N * 4 * 3 - c1;
	
	if(c1 < c0) {
		for(int i = 0; i < N * 4; i++)
			while(count[i]--) send(i);
	}else {
		send(0); send(0); send(0); send(0);
		for(int i = 0; i < N * 4; i++) {
			count[i] = 3 - count[i];
			while(count[i]--) send(i);
		}
	}
}
#include "decoder.h"
#include "decoderlib.h"

int count[1000];

void decode (int N, int L, int X[]) {
	int i, j;

	bool isc0 = false; 
	for(i = 0; i < N * 4; i++) count[i] = 0;
	for(i = 0; i < L; i++) {
		++count[X[i]];
		if(count[0] == 4) isc0 = true;
	}

	if(isc0) {
		count[0] -= 4;
		for(i = 0; i < N * 4; i++) count[i] = 3 - count[i];
	}

	for(i = 0; i < N; i++) {
		int ret = 0;
		for(j = 0; j < 4; j++) {
			ret |= count[i * 4 + j] << (2 * j);
		}

		output(ret);
	}

}
# Verdict Execution time Memory Grader output
1 Correct 4 ms 752 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 1736 KB Output is correct
2 Correct 5 ms 1768 KB Output is correct
3 Correct 5 ms 1800 KB Output is correct
4 Correct 6 ms 1800 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 2176 KB Output is correct
2 Correct 6 ms 2176 KB Output is correct
3 Correct 6 ms 2176 KB Output is correct
4 Correct 5 ms 2176 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 2264 KB Output is correct
2 Correct 5 ms 2264 KB Output is correct
3 Correct 5 ms 2264 KB Output is correct
4 Correct 8 ms 2264 KB Output is correct
5 Correct 9 ms 2272 KB Output is correct
6 Correct 8 ms 2272 KB Output is correct
# Verdict Execution time Memory Grader output
1 Partially correct 5 ms 2520 KB Output is partially correct - P = 6.250000
2 Partially correct 7 ms 2520 KB Output is partially correct - P = 6.093750
3 Partially correct 7 ms 2520 KB Output is partially correct - P = 6.121212
4 Partially correct 9 ms 2520 KB Output is partially correct - P = 6.080000
5 Partially correct 12 ms 2520 KB Output is partially correct - P = 6.066667
6 Partially correct 12 ms 2528 KB Output is partially correct - P = 6.047619
7 Partially correct 11 ms 2528 KB Output is partially correct - P = 6.062500