Submission #351736

#TimeUsernameProblemLanguageResultExecution timeMemory
351736tengiz05앵무새 (IOI11_parrots)C++17
88 / 100
11 ms1548 KiB
#include "encoder.h"
#include "encoderlib.h"
#include <bits/stdc++.h>
using namespace std;
void print(int x){
	for(int i=128;i>=0;i>>=1){
		cout << ((x>>i)&1);
	}cout << '\n';
}
int A[100];
void encode(int n, int aa[]){
	for(int i=0;i<n;i++)A[i] = aa[i];
	if(n > 32){
		for(int i=0;i<n;i++){
			while(A[i] >= 64){
				A[i] -= 64;
				send(i | (3<<6));
			}
			while(A[i] >= 16){
				A[i] -= 16;
				send(i | (2<<6));
			}
			while(A[i] >= 4){
				A[i] -= 4;
				send(i | (1<<6));
			}
			while(A[i] >= 1){
				A[i] -= 1;
				send(i | (0<<6));
			}
		}
	}else {
		for(int i=0;i<n;i++){
			while(A[i] >= 128){
				A[i] -= 128;
				send(i | (7<<5));
			}
			while(A[i] >= 64){
				A[i] -= 64;
				send(i | (6<<5));
			}
			while(A[i] >= 32){
				A[i] -= 32;
				send(i | (5<<5));
			}
			while(A[i] >= 16){
				A[i] -= 16;
				send(i | (4<<5));
			}
			while(A[i] >= 8){
				A[i] -= 8;
				send(i | (3<<5));
			}
			while(A[i] >= 4){
				A[i] -= 4;
				send(i | (2<<5));
			}
			while(A[i] >= 2){
				A[i] -= 2;
				send(i | (1<<5));
			}
			while(A[i] >= 1){
				A[i] -= 1;
				send(i | (0<<5));
			}
		}
	}
}
#include "decoder.h"
#include "decoderlib.h"
#include <bits/stdc++.h>
using namespace std;
int a[100];
void decode(int n, int len, int x[]){
	for(int i=0;i<100;i++)a[i]=0;
	if(n > 32){
		for(int i=0;i<len;i++){
			int type = (x[i] & 192)>>6;
			int ind = x[i] & 63;
			if(type == 3)a[ind] += 64;
			if(type == 2)a[ind] += 16;
			if(type == 1)a[ind] += 4;
			if(type == 0)a[ind] += 1;
		}
	}else {
		for(int i=0;i<len;i++){
			int type = (x[i] & (224))>>5;
			int ind = x[i] & 31;
			if(type == 7)a[ind] += 128;
			if(type == 6)a[ind] += 64;
			if(type == 5)a[ind] += 32;
			if(type == 4)a[ind] += 16;
			if(type == 3)a[ind] += 8;
			if(type == 2)a[ind] += 4;
			if(type == 1)a[ind] += 2;
			if(type == 0)a[ind] += 1;	
		}
	}
	//~ for(int i=0;i<n;i++)cout << a[i] << ' ';cout << '\n';	
	for(int i=0;i<n;i++)output(a[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...