Submission #916733

#TimeUsernameProblemLanguageResultExecution timeMemory
916733WansurParrots (IOI11_parrots)C++14
98 / 100
12 ms15460 KiB
#include <bits/stdc++.h>
#define f first
#define s second
#define ent '\n';

using namespace std;
typedef long long ll;
const int mx=2e5+12;

void output(int b);
void send(int a);

vector<int> g[mx];
int cnt[mx];
int p[mx];

void encode(int n, int a[]){
	int last=0;
	vector<int> x,y;
	for(int i=0;i<n;i++){
		for(int j=0;j<8;j+=2){
			if((a[i]&(1<<j))){
				x.push_back(last);
			}
			else y.push_back(last);
			if((a[i]&(1<<(j+1)))){
				x.push_back(last);
				x.push_back(last);
			}
			else{
				y.push_back(last);
				y.push_back(last);
			}
			last++;
		}
	}
	y.push_back(0);
	y.push_back(0);
	y.push_back(0);
	y.push_back(0);
	if(x.size()>y.size()){
		x.swap(y);
	}
	for(int d:x){
		send(d);
	}
}
#include <bits/stdc++.h>
#define f first
#define s second
#define ent '\n';

using namespace std;
typedef long long ll;
const int mx=2e5+12;

void output(int b);
void send(int a);

vector<int> g[mx];
int cnt[mx];
int p[mx];

void decode(int m, int n, int a[]){
	sort(a,a+n);
	for(int i=0;i<256;i++){
		cnt[i]=0;
		g[i].clear();
	}
	for(int i=0;i<n;i++){
		cnt[a[i]]++;
	}
	bool ok=0;
	if(cnt[0]>=4){
		ok=1;
		cnt[0]-=4;
	}
	for(int i=0;i<256;i++){
		if(ok)cnt[i]=3-cnt[i];
	}
	int last=0;
	for(int i=0;i<m;i++){
		int x=0;
		for(int j=0;j<8;j+=2){
			while(cnt[last]--){
				x+=(1<<j);
			}
			last++;
		}
		output(x);
	}
}
#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...