# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
767163 | raysh07 | Parrots (IOI11_parrots) | C++17 | 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;
int ok = 0;
void encode(int n, int a[])
{
ok++;
assert(ok <= 1);
// int i;
// for(i=0; i<N; i++)
// send(M[i]);
if (n < 16){
for (int i = 0; i < n; i++){
for (int j = 0; j < 8; j++){
if (a[i] >> j & 1){
send(8 * i + j);
}
}
}
return;
}
vector <int> b;
vector <pair<int, int>> f(4);
for (int i = 0; i < 4; i++){
f[i] = {0, i};
}
for (int i = 0; i < n; i++){
int copy = a[i];
for (int j = 0; j < 4; j++){
b.push_back(copy % 4);
copy /= 4;
f[b.back()].first++;
}
}
sort(f.begin(), f.end());
map <int, int> mp;
for (int i = 0; i < 4; i++){
mp[f[i].second] = 3 - i;
//send f[i].second 3 - i times
for (int j = 0; j < 4 * (3 - i); j++) send(f[i].second);
}
int val = 0;
for (auto x : b){
int y = mp[x];
for (int i = 0; i < y; i++) send(val);
val++;
}
}