# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
256272 | SamAnd | Parrots (IOI11_parrots) | C++17 | 11 ms | 1792 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"
void encode(int N, int M[])
{
int n = N;
if (false && n <= 32)
{
int z = 0;
for (int i = 0; i < n; ++i)
{
int x = M[i];
for (int j = 0; j < 8; ++j)
{
if ((x & (1 << j)))
send(z);
z++;
}
}
}
else
{
int q1 = 0;
int z = 0;
for (int i = 0; i < n; ++i)
{
int x = M[i];
for (int j = 0; j < 4; ++j)
{
if ((x & (1 << j)))
++q1;
if ((x & (1 << (j + 4))))
{
++q1;
++q1;
}
z++;
}
}
int q2 = 4;
z = 0;
for (int i = 0; i < n; ++i)
{
int x = M[i];
for (int j = 0; j < 4; ++j)
{
if (!(x & (1 << j)))
++q2;
if (!(x & (1 << (j + 4))))
{
++q2;
++q2;
}
z++;
}
}
if (q1 < q2)
{
z = 0;
for (int i = 0; i < n; ++i)
{
int x = M[i];
for (int j = 0; j < 4; ++j)
{
if ((x & (1 << j)))
send(z);
if ((x & (1 << (j + 4))))
{
send(z);
send(z);
}
z++;
}
}
}
else
{
send(0);
send(0);
send(0);
send(0);
z = 0;
for (int i = 0; i < n; ++i)
{
int x = M[i];
for (int j = 0; j < 4; ++j)
{
if (!(x & (1 << j)))
send(z);
if (!(x & (1 << (j + 4))))
{
send(z);
send(z);
}
z++;
}
}
}
}
}
#include "decoder.h"
#include "decoderlib.h"
void decode(int N, int L, int X[])
{
int c[1003] = {};
int n = N;
for (int i = 0; i < L; ++i)
++c[X[i]];
if (false && n <= 32)
{
int z = 0;
for (int i = 0; i < n; ++i)
{
int x = 0;
for (int j = 0; j < 8; ++j)
{
if (c[z])
x |= (1 << j);
z++;
}
output(x);
}
}
else
{
if (!(c[0] & 4))
{
int z = 0;
for (int i = 0; i < n; ++i)
{
int x = 0;
for (int j = 0; j < 4; ++j)
{
if ((c[z] & 1))
x |= (1 << j);
if ((c[z] & 2))
x |= (1 << (j + 4));
z++;
}
output(x);
}
}
else
{
int z = 0;
for (int i = 0; i < n; ++i)
{
int x = 0;
for (int j = 0; j < 4; ++j)
{
if (!(c[z] & 1))
x |= (1 << j);
if (!(c[z] & 2))
x |= (1 << (j + 4));
z++;
}
output(x);
}
}
}
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |