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;
namespace encoder_var {
int faken;
int a[1005];
vector< vector<int> > v;
void perm(vector<int> x, int curr) {
v.push_back(x);
if(x.size()==12) return;
for(int i=curr; i<8; i++) {
x.push_back(i);
perm(x, i);
x.pop_back();
}
}
};
void encode(int N, int M[])
{
using namespace encoder_var;
perm({}, 0);
for(int i=0; i<N; i+=2) {
int value;
if(i==N-1) {
value = M[i] * 256;
} else {
value = M[i] * 256 + M[i+1];
}
int init = i/2*8;
for(int j=0; j<v[value].size(); j++) {
send(v[value][j]+init);
}
}
}
#include "decoder.h"
#include "decoderlib.h"
#include<bits/stdc++.h>
using namespace std;
namespace decoder_var {
int faken;
int a[1005];
vector< vector<int> > v;
vector<int> tmp;
void perm(vector<int> x, int curr) {
v.push_back(x);
if(x.size()==12) return;
for(int i=curr; i<8; i++) {
x.push_back(i);
perm(x, i);
x.pop_back();
}
}
};
void decode(int N, int L, int X[])
{
using namespace decoder_var;
sort(X, X+L);
int ptr = 0;
perm({}, 0);
for(int i=0; i<64; i+=2) {
int init = i/2*8;
tmp.clear();
while(ptr<L && X[ptr]<init+8) {
tmp.push_back(X[ptr]-init);
++ptr;
}
for(int j=0; j<v.size(); j++) {
if(v[j] == tmp) {
a[i] = j/256;
a[i+1] = j%256;
break;
}
}
}
for(int i=0; i<N; i++) output(a[i]);
}
Compilation message (stderr)
encoder.cpp: In function 'void encode(int, int*)':
encoder.cpp:34:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
34 | for(int j=0; j<v[value].size(); j++) {
| ~^~~~~~~~~~~~~~~~
decoder.cpp: In function 'void decode(int, int, int*)':
decoder.cpp:36:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
36 | for(int j=0; j<v.size(); j++) {
| ~^~~~~~~~~
# | 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... |