# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
900294 | ar88lo | Parrots (IOI11_parrots) | C++14 | 0 ms | 0 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "encoder.h"
#include "encoderlib.h"
#include <bits/stdc++.h>
using namespace std;
vector<int> tovec(int a){
vector<int> ret;
for(int i = 0; i < 8; i++){
ret.push_back(a%2);
a/=2;
}
return ret;
}
int b [] = {3, 2, 1};
void encode(int N, int M[]){
vector<int> v;
for(int i = N-1; i >= 0; i--){
vector<int> temp = tovec(M[i]);
for(auto t:temp){
v.push_back(t);
}
}
reverse(v.begin(), v.end());
int ind = 0;
int times = 0;
for(int i = 0; i <v.size(); i+=2){
if(v[i] == 1 && v[i+1] == 1){
times++;
}
}
if(times > 6*N){
send(0); send(0); send(0); send(0);
reverse(b, b+3);
}
for(int i = 0; i <v.size(); i+=2){
if(v[i] == 1 && v[i+1] == 1){
for(int i = 0; i < b[0]; i++){
send(ind);
}
}
if(v[i] == 1 && v[i+1] == 0){
for(int i = 0; i < b[1]; i++){
send(ind);
}
}
if(v[i] == 0 && v[i+1] == 1){
for(int i= 0; i < b[2]; i++){
send(ind);
}
}
ind++;
}
}