# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
772955 | PoonYaPat | 앵무새 (IOI11_parrots) | C++14 | 4 ms | 1304 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> v;
void put(int x) {
for (int i=0; i<8; ++i) {
if (x&(1<<i)) v.push_back(1);
else v.push_back(0);
}
}
void encode(int N, int M[]) {
v.clear();
for (int i=0; i<N; ++i) put(M[i]);
for (int i=0; i+1<v.size(); i+=2) {
//consider bit i and i+1
if (v[i]==v[i+1]) send(i+v[i]);
else {
send(i);
if (v[i]==0) send(i);
else send(i+1);
}
}
}
#include "decoder.h"
#include "decoderlib.h"
#include <bits/stdc++.h>
using namespace std;
vector<int> ans,group[128];
void decode(int N, int len, int X[]) {
ans.clear();
for (int i=0; i<128; ++i) group[i].clear();
for (int i=0; i<len; ++i) group[X[i]/2].push_back(X[i]%2);
for (int i=0; i<128; ++i) {
if (group[i].size()==0) break;
if (group[i].size()==1) {
ans.push_back(group[i][0]);
ans.push_back(group[i][0]);
} else {
if (group[i][0]==group[i][1]) {
ans.push_back(0);
ans.push_back(1);
} else {
ans.push_back(1);
ans.push_back(0);
}
}
}
for (int i=0; i+7<ans.size(); i+=8) {
int res=0,mul=1;
for (int j=0; j<8; ++j) {
if (ans[i+j]==1) res+=mul;
mul*=2;
}
output(res);
}
}
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... |