이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "encoder.h"
#include "encoderlib.h"
#include <bits/stdc++.h>
using namespace std;
static map<int, bool> lank;
static map<int, pair<int, int>> perm;
static int b[7];
static int iSkaiciu()
{
int s=0;
for (int i=0; i<7; i++)
s+=b[i]<<(2*i);
return s;
}
static void pildyti(int L)
{
int val=iSkaiciu();
if (lank.count(val))
return;
lank[val]=1;
perm[perm.size()]={L, val};
for (int i=0; i<L; i++)
if ((i==L-1 && b[i]<3) || (i<L-1 && b[i]<b[i+1]))
{
b[i]++;
pildyti(L);
b[i]--;
}
}
void encode(int N, int M[])
{
for (int i=0; i<=7; i++)
{
pildyti(i);
lank.clear();
}
for (int i=0; i<N; i++)
for (int j=0; j<perm[M[i]].first; j++)
{
send((i<<2)+((perm[M[i]].second>>(2*j))&3));
// cout<<((i<<2)+((perm[M[i]].second>>(2*j))&3))<<endl;
}
}
#include "decoder.h"
#include "decoderlib.h"
#include <bits/stdc++.h>
using namespace std;
static map<int, bool> lank2;
static map<pair<int, int>, int> perm2;
static int b[7];
static int iSkaiciu()
{
int s=0;
for (int i=0; i<7; i++)
s+=b[i]<<(2*i);
return s;
}
static void pildyti(int L)
{
int val=iSkaiciu();
if (lank2.count(val))
return;
lank2[val]=1;
perm2[{L, val}]=perm2.size();
for (int i=0; i<L; i++)
if ((i==L-1 && b[i]<3) || (i<L-1 && b[i]<b[i+1]))
{
b[i]++;
pildyti(L);
b[i]--;
}
}
void decode(int N, int L, int X[])
{
vector<int> B[N];
for (int i=0; i<=7; i++)
{
pildyti(i);
lank2.clear();
}
for (int i=0; i<L; i++)
B[X[i]>>2].push_back(X[i]&3);
for (int i=0; i<N; i++)
{
sort(B[i].begin(), B[i].end());
int s=0;
for (long unsigned int j=0; j<B[i].size(); j++)
s+=B[i][j]<<(2*j);
output(perm2[{B[i].size(), s}]);
}
}
# | 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... |