# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
636092 | Do_you_copy | Parrots (IOI11_parrots) | C++17 | 6 ms | 1236 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>
#define pb push_back
using namespace std;
using pii = pair <int, int>;
void encode(int N, int M[])
{
vector <int> v = {0, 1, 2, 3};
vector <int> sex;
vector <int> pos[4];
for (int i = 0; i < N; ++i){
vector <int> bit;
int x = M[i];
for (int j = 0; j < 4; ++j){
bit.pb(x % 4);
x /= 4;
}
reverse(bit.begin(), bit.end());
for (int j = 0; j < 4; ++j){
pos[bit[j]].pb(i * 4 + j);
}
}
int cnt = 0;
pii minn = {INT_MAX, 0};
int a[] = {pos[0].size(), pos[1].size(), pos[2].size(), pos[3].size()};
do{
++cnt;
minn = min(minn, {v[0] * a[0] + v[1] * a[1] + v[2] * a[2] + v[3] * a[3], cnt});
} while (next_permutation(v.begin(), v.end()));
sort(v.begin(), v.end());
int cnt2 = 1;
while (cnt2 != minn.second){
++cnt2;
next_permutation(v.begin(), v.end());
}
vector <int> v1(4);
v1[v[0]] = 0;
v1[v[1]] = 1;
v1[v[2]] = 2;
v1[v[3]] = 3;
v = v1;
for (int i = 0; i < 4; ++i) sex.pb(cnt2);
for (int i = 0; i < 4; ++i){
for (int j: pos[i]){
for (int k = 0; k < v[i]; ++k) sex.pb(j);
}
}
for (int i: sex) send(i);
}
#include "decoder.h"
#include "decoderlib.h"
#include <bits/stdc++.h>;
using namespace std;
void decode(int N, int L, int X[])
{
vector <int> bit(257, 0);
vector <int> ans(65, 0);
sort(X, X + L);
vector <int> v{0, 1, 2, 3};
int cnt = 0;
for (int i = 0; i < L - 3; ++i){
if (X[i] == X[i + 1] && X[i + 1] == X[i + 2] && X[i + 2] == X[i + 3]){
cnt = X[i];
X[i] = X[i + 1] = X[i + 2] = X[i + 3] = 300;
}
}
int cnt2 = 1;
while (cnt2 != cnt){
++cnt2;
next_permutation(v.begin(), v.end());
}
int power[] = {1, 4, 16, 64};
for (int i = 0; i < L; ++i){
if (i > 256) continue;
++bit[X[i]];
}
for (int i = 0; i < N * 4; ++i) bit[i] = v[bit[i]];
for (int i = 0; i < N; ++i){
ans[i] = bit[i * 4] * power[3] + bit[i * 4 + 1] * power[2] + bit[i * 4 + 2] * power[1] + bit[i * 4 + 3] * power[0];
}
for (int i = 0; i < N; ++i) output(ans[i]);
}
Compilation message (stderr)
# | 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... |