#include "encoder.h"
#include "encoderlib.h"
void encode(int N, int M[])
{
int i;
if (N > 32) {
int mask = 0x000f;
for (i = 0; i < N; i++) {
int seq = i << 2;
int temp = M[i]&mask;
for (int j = 0; j < 4; j++) {
if (temp & 1) {
send(seq + j);
}
temp >>= 1;
}
temp = (M[i] >> 4)&mask;
for (int j = 0; j < 4; j++) {
if (temp & 1) {
send(seq + j);
send(seq + j);
}
temp >>= 1;
}
}
return;
}
for (i = 0; i < N; i++) {
int seq = i << 3;
int temp = M[i];
for (int j = 0; j < 8; j++) {
if (temp & 1) {
send(seq + j);
}
temp >>= 1;
}
}
}
#include "decoder.h"
#include "decoderlib.h"
#include<algorithm>
#include<vector>
using namespace std;
void decode(int N, int L, int X[])
{
int i, mask = 0x0007, mask2 = 0x0003;
int b[64];
for (int i = 0; i < 64; i++)
b[i] = 0;
sort(X, X + L);
int seq = 0, ans = 0;
if (N > 32) {
vector<int> Y;
int temp = ((X[0] >> 2) << 3) + (X[0] & mask2);
Y.push_back(temp);
for (i = 1; i < L; i++) {
temp = ((X[i] >> 2) << 3) + (X[i] & mask2);
if (temp^Y.back()) {
Y.push_back(temp);
continue;
}
Y.pop_back();
Y.push_back(temp + 4);
}
sort(Y.begin(), Y.end());
for (i = 0; i < Y.size(); i++) {
if ((Y[i] >> 3) ^ seq) {
b[seq] = ans;
ans = 0;
seq = Y[i] >> 3;
}
ans += (1 << (Y[i] & mask));
}
b[seq] = ans;
for (i = 0; i < N; i++)
output(b[i]);
return;
}
for(i=0; i<L; i++) {
if ((X[i] >> 3)^seq) {
b[seq] = ans;
ans = 0;
seq = X[i] >> 3;
}
ans += (1 << (X[i] & mask));
}
b[seq] = ans;
for (int i = 0; i < N; i++)
output(b[i]);
}
Compilation message
decoder.cpp: In function 'void decode(int, int, int*)':
decoder.cpp:36:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (i = 0; i < Y.size(); i++) {
~~^~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
752 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
1592 KB |
Output is correct |
2 |
Correct |
8 ms |
1864 KB |
Output is correct |
3 |
Correct |
8 ms |
1992 KB |
Output is correct |
4 |
Correct |
7 ms |
2024 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
2096 KB |
Output is correct |
2 |
Correct |
7 ms |
2128 KB |
Output is correct |
3 |
Correct |
7 ms |
2128 KB |
Output is correct |
4 |
Correct |
7 ms |
2144 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
2144 KB |
Output is correct |
2 |
Correct |
6 ms |
2144 KB |
Output is correct |
3 |
Correct |
7 ms |
2144 KB |
Output is correct |
4 |
Correct |
9 ms |
2144 KB |
Output is correct |
5 |
Correct |
11 ms |
2144 KB |
Output is correct |
6 |
Correct |
9 ms |
2144 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
10 ms |
2176 KB |
Output is partially correct - P = 8.000000 |
2 |
Partially correct |
9 ms |
2184 KB |
Output is partially correct - P = 8.000000 |
3 |
Incorrect |
10 ms |
2184 KB |
Error : Output is wrong |
4 |
Incorrect |
14 ms |
2184 KB |
Error : Output is wrong |
5 |
Incorrect |
16 ms |
2432 KB |
Error : Output is wrong |
6 |
Incorrect |
13 ms |
2432 KB |
Error : Output is wrong |
7 |
Incorrect |
13 ms |
2432 KB |
Error : Output is wrong |