# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
386916 | godwind | 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 <vector>
using namespace std;
void encode(int n, int M[])
{
vector<int> is(n);
for (int i = 0; i < n; ++i) {
int FIRST = M[i] / 16;
int SECOND = M[i] % 16;
send(FIRST * 16 + i);
send(SECOND * 16 + i);
if (FIRST < SECOND) {
is[i] = false;
} else {
is[i] = true;
}
}
int mask = 0;
for (int i = 0; i < n; ++i) {
if (is[i]) {
mask += (1 << i);
}
}
for (int it = 0; it < 10; ++it) {
send(mask);
}
}
#include "decoder.h"
#include "decoderlib.h"
#include <vector>
#include <map>
using namespace std;
void decode(int n, int L, int X[])
{
vector<int> ans(n), is(n);
vector< vector<int> > parts(n);
map<int, int> cnt;
for (int i = 0; i < L; ++i) {
++cnt[X[i]];
}
auto proceed = [&] (int mask) {
int FP = mask / 16;
int SP = mask % 16;
int id = SP;
parts[id].push_back(FP);
};
for (auto P : cnt) {
int mask = P.first;
int cn = p.second;
if (cn == 1) {
proceed(mask);
} else {
if (cn == 10) {
for (int i = 0; i < n; ++i) {
is[i] = (mask >> i) & 1;
}
} else {
proceed(mask);
}
}
}
for (int i = 0; i < n; ++i) {
sort(parts[i].begin(), parts[i].end());
if (is[i]) {
ans[i] = parts[i][1] * 16 + parts[i][0];
} else {
ans[i] = parts[i][0] * 16 + parts[i][1];
}
}
for (int i = 0; i < n; ++i) {
output(ans[i]);
}
}