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 <bits/stdc++.h>
#include "encoder.h"
#include "encoderlib.h"
#include <string>
#include<map>
#include<algorithm>
using namespace std;
long long mapa2[92400];
int broj = 0;
map<long long ,int> mapa;
void rec(int posledno, int n, long long s,int depth){
if(depth==n)
{
mapa[s]=broj;
// mapa2[broj]=s;
//cout<<s<<" "<<broj<<endl;
broj++;
return;
}
for(long long i =posledno;i<n;i++)
{
rec(i,n,s*10LL+i,depth+1);
}
}
void rec2(int posledno, int n, long long s,int depth){
if(depth==n)
{
//mapa[s]=broj;
mapa2[broj]=s;
//cout<<s<<" "<<broj<<endl;
broj++;
return;
}
for(long long i =posledno;i<n;i++)
{
rec2(i,n,s*10LL+i,depth+1);
}
}
void encode(int n, int a[])
{
rec2(0,10,0,0);
int nn = n;
if (nn%2==1)
nn++;
int b[nn*8];
int suma=0;
int start_from = 0;
for(int i =0;i<n;i++)
{
if (i%2==0)
suma = a[i];
else
suma = (suma<<8)+a[i];
if (i%2==1 || i==n-1)
{
if (i==n-1 && n%2==1)
suma<<=8;
string s= "";
long long x= mapa2[suma];
while (x>0)
{
s=(char)(x%10 + '0') + s;
x/=10;
}
while (s.size()<10)
s="0"+s;
// cout<<s<<endl;
int array_to_send[10];
for(int j =0;j<10;j++)
{
int brojce = (int)(s[j]-'0');
send(start_from+brojce);
// if (i==n-1 && n%2==1 && j==4)
// break;
}
start_from+=10;
suma=0;
}
}
}
#include <bits/stdc++.h>
#include "decoder.h"
#include "decoderlib.h"
#include <string>
#include<map>
#include<algorithm>
using namespace std;
long long mapa2[92400];
int broj = 0;
map<long long ,int> mapa;
void rec(int posledno, int n, long long s,int depth){
if(depth==n)
{
mapa[s]=broj;
// mapa2[broj]=s;
//cout<<s<<" "<<broj<<endl;
broj++;
return;
}
for(long long i =posledno;i<n;i++)
{
rec(i,n,s*10LL+i,depth+1);
}
}
void rec2(int posledno, int n, long long s,int depth){
if(depth==n)
{
//mapa[s]=broj;
mapa2[broj]=s;
//cout<<s<<" "<<broj<<endl;
broj++;
return;
}
for(long long i =posledno;i<n;i++)
{
rec2(i,n,s*10LL+i,depth+1);
}
}
void decode(int n,int howmany2,int a[]){
broj = 0;
rec(0,10,0,0);
sort(a,a+howmany2);
/* for(int i =0;i<howmany2;i++)
cout<<a[i]<<" ";
cout<<endl;*/
long long s=0;
int mod = 1<<8;
int start_from = 0;
for(int i =0;i<howmany2;i++)
{
s=s*10LL+ (long long)(a[i]-start_from);
if (i%10==9 || i==howmany2-1)
{
//cout<<s<<endl;
//if (i==howmany2-1 && n%2==1)
//for(int j =0;j<5;j++)
// s+=s[5];
int converted = mapa[s];
output(converted/mod);
if (i==howmany2-1 && n%2==1)
break;
output(converted%mod);
start_from+=10;
s=0;
}
}
}
Compilation message (stderr)
encoder.cpp: In function 'void encode(int, int*)':
encoder.cpp:68:7: warning: this 'else' clause does not guard... [-Wmisleading-indentation]
68 | else
| ^~~~
encoder.cpp:71:9: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'else'
71 | if (i%2==1 || i==n-1)
| ^~
encoder.cpp:89:17: warning: unused variable 'array_to_send' [-Wunused-variable]
89 | int array_to_send[10];
| ^~~~~~~~~~~~~
encoder.cpp:58:9: warning: unused variable 'b' [-Wunused-variable]
58 | int b[nn*8];
| ^
# | 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... |