This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#ifndef SKY
#include "encoder.h"
#include "encoderlib.h"
#endif // SKY
#include <bits/stdc++.h>
using namespace std;
#ifdef SKY
vector<int> tokens;
void send(int x) {
tokens.push_back(x);
}
#endif // SKY
void sub64(int N, int M[])
{
for(int i=0;i<N;i++)
{
int u=M[i];
for(int j=0;j<4;j++)
{
for(int t=1;t<=u%4;t++)
send((i<<2)+j);
u>>=2;
}
}
}
void encode(int N, int M[])
{
if(N>32)
{
sub64(N,M);
return;
}
for(int i=0;i<N;i++)
for(int j=0;j<8;j++)
if((M[i]>>j)&1)
{
send((i<<3)+j);
}
}
#ifdef SKY
int main(void) {
freopen("ENCODE.inp","r",stdin);
freopen("ENCODE.out","w",stdout);
srand(time(0));
int n; cin >> n;
int a[n];
for (int i = 0; i < n; i++) cin >> a[i];
encode(n, a);
cout << n << endl;
cout << tokens.size() << endl;
for (int x : tokens) cout << x << " " ; cout << endl;
return 0;
}
#endif // SKY
#ifndef SKY
#include "decoder.h"
#include "decoderlib.h"
#endif // SKY
#include <bits/stdc++.h>
using namespace std;
#ifdef SKY
vector<int> tokens;
void output(int b) {
cout<<b<<" ";
}
#endif // SKY
void decode(int n, int l,int X[])
{
int kq[n]={};
if(n>32)
{
int kq[n][4]={};
for(int i=0;i<l;i++)
{
int vt=(X[i]>>2),j=(X[i]&3);
// cout<<vt<<" "<<j<<endl;
kq[vt][j]++;
}
for(int i=0;i<n;i++)
{
int res=0;
for(int j=0;j<4;j++)
{
res+=(kq[i][j]<<(j*2));
}
output(res);
}
return;
}
for(int i=0; i<l; i++)
kq[X[i]>>3]+=(1<<(X[i]&((1<<3)-1)));
for(int i=0;i<n;i++)
output(kq[i]);
}
#ifdef SKY
int main(void) {
freopen("DECODE.inp","r",stdin);
freopen("DECODE.out","w",stdout);
int n,l;
cin>>n>>l;
int a[l];
for(int i=0;i<l;i++)
cin>>a[i];
decode(n,l,a);
return 0;
}
#endif // SKY
# | 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... |