제출 #105380

#제출 시각아이디문제언어결과실행 시간메모리
105380eriksuenderhauf앵무새 (IOI11_parrots)C++11
98 / 100
15 ms1792 KiB
#include "encoder.h"
#include "encoderlib.h"
int a[800];

void encode(int n, int M[]) {
	int cnt = 0, x = 0, y = 0;
	for (int i = 0; i < n; i++) {
		for (int j = 7; j > -1; j--) {
			if ((M[i] >> j) & 1)
				a[cnt++] = 1;
			else
				a[cnt++] = 0;
			if (cnt % 2 == 0) {
				x += a[cnt-1] * 2 + a[cnt-2];
				y += 3 - (a[cnt-1] * 2 + a[cnt-2]);
			}
		}
	}
	if (x > y) {
		send(0); send(0); send(0); send(0);
    }
	for (int i = 0; i < cnt; i += 2)
		if (x > y)
			for (int j = 0; j < 3 - (a[i+1] * 2 + a[i]); j++)
				send(i / 2);
		else
			for (int j = 0; j < a[i+1] * 2 + a[i]; j++)
				send(i / 2);
}
#include <bits/stdc++.h>
#include "decoder.h"
#include "decoderlib.h"
int a2[800], b[800];
int val[16] = {0, 0, 1, 0, 0, 1, 1, 1, 1, 1, 0, 1, 1, 0, 0, 0};
 
void decode(int n, int L, int X[]) {
  	memset(b, 0, sizeof b);
	std::sort(X, X + L);
	int fl = 0;
	if (L > 3 && X[0] == X[1] && X[2] == X[3] && X[0] == X[2] && X[0] == 0)
		fl = 4;
	int cur = fl;
	for (int i = 0; i < 4 * n; i++) {
		int j = cur;
		while (cur < L && X[cur] == i) cur++;
		j = cur - j;
		a2[2 * i] = val[2 * j + 2 * fl];
		a2[2 * i + 1] = val[2 * j + 1 + 2 * fl];
	}
	for (int i = 0; i < n; i++) {
		for (int j = 7; j > -1; j--)
			b[i] |= (1 << j) * a2[8 * (i + 1) - j - 1];
		output(b[i]);
	}
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...