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>
#define fi first
#define se second
#define ll long long
#define dl double long
using namespace std;
const int maxn = 1e5 + 7;
int x;
char b[maxn];
vector < string > v;
vector < char > g = { '0' , '1' , '2' , '3' };
void foo( int i )
{
if( i == x ){
string t = "";
for( int j = 0; j < i; j++ ){
t += b[j];
}
v.push_back(t);
return;
}
for( auto y : g ){
if( i && b[i - 1] > y )continue;
b[i] = y;
foo( i + 1 );
}
}
void encode(int n, int a[])
{
for( int i = 1; i <= 7; i++ ){
x = i;
foo( 0 );
}
for( int i = 0; i < n; i++ ){
for( auto c : v[a[i]] ){
int s = i;
int xx = c - '0';
send( s + (xx << 6) );
}
}
}
#include "decoder.h"
#include "decoderlib.h"
#include <bits/stdc++.h>
#define fi first
#define se second
#define ll long long
#define dl double long
using namespace std;
int x;
char b[10000];
vector < string > v;
vector < char > g = { '0' , '1' , '2' , '3' };
void foo( int i )
{
if( i == x ){
string t = "";
for( int j = 0; j < i; j++ ){
t += b[j];
}
v.push_back(t);
return;
}
for( auto y : g ){
if( i && b[i - 1] > y )continue;
b[i] = y;
foo( i + 1 );
}
}
void decode(int n, int l, int a[])
{
for( int i = 1; i <= 7; i++ ){
x = i;
foo( 0 );
}
vector < vector < char > > g(256);
for( int i = 0; i < l; i++ ){
int pos = (a[i] & ((1 << 6) - 1));
int x = (a[i] >> 6);
g[pos].push_back((char)(x + '0'));
}
for( int i = 0; i < n; i++ ){
sort( g[i].begin() , g[i].end() );
string t = "";
for( auto c : g[i] )t += c;
for( int j = 0; j < 256; j++ ){
if( v[j] == t ){
output(j);
break;
}
}
}
}
# | 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... |