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 <vector>
#include <iostream>
#include "encoder.h"
#include "encoderlib.h"
/*
#include "decoder.h"
#include "decoderlib.h"
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include "encoder.h"
#include "encoderlib.h"
#include <bits/stdc++.h>
*/
using namespace std;
const int MAXN = 257;
int cnt[MAXN][4];
void encode(int N, int M[]){
vector<int> res;
for(int i=0;i<256;i++){
int flag = 1;
for(int j=0;j<=5;j++){
for(int k=0;k<=5;k++){
for(int d=0;d<=5;d++){
for(int c=0;c<=5;c++){
if(j+4*k+16*d+64*c==i){
cnt[i][0] = j;
cnt[i][1] = k;
cnt[i][2] = d;
cnt[i][3] = c;
}
}
}
}
}
}
vector<int> packet;
for(int i=0;i<N;i++){
int bit = i<<3;
int mx1 = max(cnt[M[i]][0],cnt[M[i]][1]); //1 4
int mx2 = max(cnt[M[i]][2],cnt[M[i]][3]); //16 64
int t1 = cnt[M[i]][0]; int t2 = cnt[M[i]][1]; int flag = 0;
for(int j=1;j<=mx1;j++){
int add = bit + flag;
if(t1>0)add |= 1; //1
if(t2>0)add |= 2; //4
t1--; t2--;
packet.push_back(add);
}
t1 = cnt[M[i]][2]; t2 = cnt[M[i]][3];
for(int j=1;j<=mx2;j++){
int add = bit + 4;
if(t1>0) add |= 1;
if(t2>0) add |= 2;
t1--; t2--;
packet.push_back(add);
}
if(mx1 == 0 && mx2 == 0){
packet.push_back(bit);
}
}
for(int num:packet) send(num);
}
#include <vector>
#include <iostream>
#include "decoder.h"
#include "decoderlib.h"
using namespace std;
void decode(int N, int L, int X[]){
vector<int> res(N,0);
if(N<=32){
for(int i=0;i<L;i++){
int loc = X[i]/8;
int flag = X[i] & 4;
int num = 0;
if(!flag){
if(X[i] & 1) num += 1;
if(X[i] & 2) num += 4;
//1 4 ()
}
else{
if(X[i] & 1) num += 16;
if(X[i] & 2) num += 64;
// 16 64
}
res[loc] += num;
}
}
else{
}
for(int num:res) output(num);
}
Compilation message (stderr)
encoder.cpp: In function 'void encode(int, int*)':
encoder.cpp:32:13: warning: unused variable 'flag' [-Wunused-variable]
int flag = 1;
^~~~
# | 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... |