# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
771298 | iulia13 | 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 <bits/stdc++.h>
#include "encoder.h"
#include "encoderlib.h"
using namespace std;
const int N = 513;
void encode(int n, int a[])
{
int cnt = 0, i = 0, ok = 0, tot = 3 * 128;
while (cnt <= 248 && i < n)
{
int nr = 128;
while(nr)
{
if (a[i] & nr)
ok++;
nr /= 2;
cnt++;
}
i++;
}
while (cnt <= 504 && i < n)
{
int nr = 128;
while (nr)
{
if (a[i] & nr)
{
ok += 2;
//send(cnt - 256);
//send(cnt - 256);
}
nr /= 2;
cnt++;
}
i++;
}
if (ok <= tot)
ok = 1;
else
ok = 0;
cnt = i = 0;
while (cnt <= 248 && i < n)
{
int nr = 128;
while(nr)
{
if ((a[i] & nr) == nr * ok)
send(cnt);
nr /= 2;
cnt++;
}
i++;
}
while (cnt <= 504 && i < n)
{
int nr = 128;
while (nr)
{
if ((a[i] & nr) == nr * ok)
{
send(cnt - 256);
send(cnt - 256);
}
nr /= 2;
cnt++;
}
i++;
}
if (!ok)
{
send(0);
send(0);
send(0);
send(0);
}
return;
}
#include <bits/stdc++.h>
#include "decoder.h"
#include "decoderlib.h"
using namespace std;
int vf[N];
int ans[N];
int bits[N];
void decode(int n, int l, int a[])
{
for (int i = 0; i < l; i++)
{
vf[a[i]]++;
}
if (vf[0] >= 4)
{
for (int i = 0; i < n; i++)
bits[i] = 1;
}
for (int i = 0; i < 256; i++)
{
if (vf[i] & 1)
bits[i] |= 1;
if (vf[i] & 2)
bits[i] |= 1;
}
int j = 0;
for (int i = 0; i < n; i++)
{
int nr = 128;
while (nr)
{
ans[i] += bits[j] * nr;
nr /= 2;
j++;
}
output(ans[i]);
}
return;
}