Submission #795057

#TimeUsernameProblemLanguageResultExecution timeMemory
795057khshgParrots (IOI11_parrots)C++14
0 / 100
5 ms1344 KiB
#include "encoder.h"
#include "encoderlib.h"
#include <bits/stdc++.h>
using namespace std;
 
void encode(int N, int M[]) {
	vector<int> go;
	int cnt = 0;
	for(int i = 0; i < N; ++i) {
		for(int j = 0; j < 4; ++j) {
			int B = (M[i] >> (6 - 2 * j));
			B &= 3;
			cnt += B;
		}
	}
	if(N * 2 * 3 <= cnt) {
		for(int i = 0; i < 4; ++i) send(0);
		for(int i = 0; i < N; ++i) {
			for(int j = 0; j < 4; ++j) {
				int B = (M[i] >> (6 - 2 * j));
				B &= 3;
				B = 3 - B;
				while(B--) send(j + (i << 2));
			}
		}
		return;
	}
	for(int i = 0; i < N; ++i) {
		for(int j = 0; j < 4; ++j) {
			int B = (M[i] >> (6 - 2 * j));
			B &= 3;
			while(B--) send(j + (i << 2));
		}
	}
}
#include "decoder.h"
#include "decoderlib.h"
#include <bits/stdc++.h>
using namespace std;
 
void decode(int N, int L, int X[]) {
	bool rev = 0;
	sort(X, X + L);
	if(L >= 4 && X[3] == 0) {
		rev = 1;
	}
	vector<array<int, 4>> cnt(N, {0, 0, 0, 0});
	for(int i = (rev ? 4 : 0); i < L; ++i) {
		++cnt[(X[i] >> 2)][(X[i] & 3)];
	}
	if(rev)
	for(int i = 0; i < N; ++i) {
		for(int j = 0; j < 4; ++j) cnt[i][j] = 3 - cnt[i][j];
	}
	vector<int> ans;
	for(int i = 0; i < N; ++i) {
		for(int j = 0; j < 4; ++j)
			ans[i] ^= (cnt[i][j] << (6 - 2 * j));
	}
	for(int i = 0; i < N; ++i) {
		output(ans[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...