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 {
vector <vector <int>> can;
vector <int> v;
int cnt;
void backtrack(int cur, int last) {
if(can.size() > 256) return ;
if(cur == 0) {
can.push_back(v);
++cnt;
return ;
}
for(int i = last; i < 4; i++) {
v.push_back(i);
backtrack(cur - 1, i);
v.pop_back();
}
}
}
void encode(int N, int M[])
{
for(int i = 1; i <= 7; i++) {
backtrack(i, 0);
}
int i;
for(i=0; i<N; i++) {
vector <int> v = can[M[i]];
for(int j : v) {
send(4 * i + j);
}
}
}
#include "decoder.h"
#include "decoderlib.h"
#include "bits/stdc++.h"
using namespace std;
namespace {
vector <vector <int>> can;
vector <int> v;
int cnt;
void backtrack(int cur, int last) {
if(can.size() > 256) return ;
if(cur == 0) {
can.push_back(v);
++cnt;
return ;
}
for(int i = last; i < 4; i++) {
v.push_back(i);
backtrack(cur - 1, i);
v.pop_back();
}
}
}
void decode(int N, int L, int X[])
{
for(int i = 1; i <= 7; i++) {
backtrack(i, 0);
}
vector <int> v[N + 1];
for(int i = 0; i < L; i++) {
v[X[i] / 4].push_back(X[i] % 4);
}
for(int i = 0; i < N; i++) {
sort(v[i].begin(), v[i].end());
for(int j = 0; j < can.size(); j++) {
if(can[j] == v[i]) {
output(j);
break;
}
}
}
}
Compilation message (stderr)
decoder.cpp: In function 'void decode(int, int, int*)':
decoder.cpp:35:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int j = 0; j < can.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... |