# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
500665 | aryan12 | Parrots (IOI11_parrots) | C++17 | 9 ms | 1356 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;
vector<int> base4conv(int x) {
int lmao = 64;
vector<int> ans;
while(lmao != 0) {
int ok = x / lmao;
x -= ok * lmao;
ans.push_back(ok);
lmao /= 4;
}
return ans;
}
void encode(int N, int M[]) {
if(N <= 32) {
for(int i = 0; i < N; i++) {
vector<int> pos1;
int cnt1 = 0;
for(int j = 0; j < 9; j++) {
if((1 << j) & M[i]) {
cnt1++;
pos1.push_back(j);
}
}
int sent_num = 0;
sent_num += (8 * i);
for(int j = 0; j < pos1.size(); j++) {
send(sent_num + pos1[j]);
}
}
}
else {
for(int i = 0; i < N; i++) {
vector<int> cur = base4conv(M[i]);
for(int j = 0; j < cur.size(); j++) {
for(int k = 0; k < cur[j]; k++) {
// cout << "i = " << i << ", j = " << j << ", val = " << i * 4 + j << "\n";
send(i * 4 + j);
}
}
}
}
}
#include "decoder.h"
#include "decoderlib.h"
#include <bits/stdc++.h>
using namespace std;
void decode(int N, int L, int X[]) {
if(N <= 32) {
vector<int> one_bits[N];
for(int i = 0; i < L; i++) {
int cur_num = X[i];
int pos = cur_num / 8;
cur_num %= 8;
one_bits[pos].push_back(cur_num);
}
for(int i = 0; i < N; i++) {
int ans = 0;
for(int j = 0; j < one_bits[i].size(); j++) {
ans += (1 << one_bits[i][j]);
}
output(ans);
}
}
else {
int check[256] = {0};
for(int i = 0; i < L; i++) {
check[X[i]]++;
}
for(int i = 0; i < N * 4; i += 4) {
int ok = 64, ans = 0;
for(int j = 0; j < 4; j++) {
int idx = i + j;
ans += (ok * check[idx]);
ok /= 4;
}
output(ans);
}
}
}
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... |