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<cmath>
#include<cstdio>
bool a[9];
void encode(int N, int M[])
{
for(int i=0; i<N; i++) {
for(int b=0; b<9; b++) a[b] = false;
int n = M[i];
int msg=i;
// printf("%d sayi var i=%d\n",N, i);
msg = msg<<2;
// printf("msg %d\n", msg);
//n sayisi ikilik tabana donusturule
for(int j=7; j>-1; j--) {
if( n>=pow(2,j) ) {
a[j] = true;
// printf("%d true\n", j);
n-=pow(2,j);
}
}
//printf("hebele\n");
for(int j=0; j<4; j++) {
if(a[2*j] and a[2*j+1]) { /*printf("%d 3 kere\n", j);*/ send(msg+j); send(msg+j); send(msg+j); }
else if(a[2*j]) { send(msg+j); /*printf("%d 1 kere\n", j); */}
else if(a[2*j+1]) {/*printf("%d 2 kere\n", j); */send(msg+j); send(msg+j); }
}
}
/*int i;
for(i=0; i<N; i++)
send(M[i]);*/
}
#include "decoder.h"
#include "decoderlib.h"
#include<cmath>
#include<cstdio>
#include<bits/stdc++.h>
using namespace std;
int as[66][6];
void decode(int N, int L, int X[])
{
for(int i=0; i<L; i++) {
// printf("kod %d\n", X[i]);
int n = X[i];
n = n>>2;
int k = X[i]%4;
as[n][k]++;
// printf("%d . sayinin %d . bit ikilisi\n", n, k);
}
for(int i=0; i<N; i++) {
int msg = 0;
for(int j=0; j<4; j++) msg+= as[i][j]*pow(2,2*j);
output(msg);
//printf("%d\n", msg);
}
//int i, b;
}
# | 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... |