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;
#define type(x) __typeof((x).begin())
#define foreach(it, x) for(type(x) it = (x).begin(); it != (x).end(); it++)
typedef long long ll;
typedef pair < int, int > ii;
const int inf = 1e9 + 333;
const ll linf = 1e18 + inf;
const int N = 100 + 5;
vector < int > v1, v2;
void encode(int n, int a[]) {
for(int i = 0; i < n; i += 2) {
for(int p = 0; p < 8; p++) {
int x = ((a[i] >> p) & 1) * 2 + (i + 1 < n ? ((a[i + 1] >> p) & 1) : 0);
for(int j = 0; j < x; j++)
v1.push_back(i / 2 * 8 + p);
for(int j = 0; j < 3 - x; j++)
v2.push_back(i / 2 * 8 + p);
}
}
if(0 and v1.size() > v2.size()) {
v1.swap(v2);
v1.push_back(255);
v1.push_back(255);
v1.push_back(255);
v1.push_back(255);
}
foreach(it, v1) {
int x = *it;
send(x);
}
}
#include "decoder.h"
#include "decoderlib.h"
#include <bits/stdc++.h>
using namespace std;
#define type(x) __typeof((x).begin())
#define foreach(it, x) for(type(x) it = (x).begin(); it != (x).end(); it++)
typedef long long ll;
typedef pair < int, int > ii;
const int inf = 1e9 + 333;
const ll linf = 1e18 + inf;
const int N = 100 + 5;
int cnt[500];
static int pw[6];
int ans[N];
void decode(int n, int m, int a[]) {
for(int i = 0; i < m; i++)
cnt[a[i]]++;
if(cnt[255] >= 4) {
cnt[255] -= 4;
for(int i = 0; i < 256; i++)
cnt[i] = 3 - cnt[i];
int sz = 0;
for(int i = 0; i < 256; i++)
while(cnt[i]) {
a[sz++] = i;
cnt[i]--;
}
}
for(int i= 0; i < 256; i++) {
int x = i / 8 * 2;
int k = i % 8;
if(cnt[i] & 2)
ans[x] += 1 << k;
if(cnt[i] & 1)
ans[x + 1] += 1 << k;
}
for(int i = 0; i < n; i++) {
//printf("%d ", ans[i]);
output(ans[i]);
}
puts("");
}
Compilation message (stderr)
decoder.cpp:20:12: warning: 'pw' defined but not used [-Wunused-variable]
static int pw[6];
^~
# | 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... |