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>
void encode(int N, int M[])
{
bool bit = true;
for(int i=0; i<8; i++) if(M[i]!=0 and M[i]!=1) bit= false;
if(N==8 and bit) {
int msg = 0;
for(int i=0; i<N; i++) {
msg+= M[i]*pow(2, i);
// printf("%d eklendi\n", (int)pow(2,i)*M[i]);
}
// printf("%d\n", msg);
send(msg);
send(msg);
}
/*int i;
for(i=0; i<N; i++)
send(M[i]);*/
}
#include "decoder.h"
#include "decoderlib.h"
#include<cmath>
#include<cstdio>
void decode(int N, int L, int X[])
{
//int i, b;
if(N==8 and X[0]==X[1] ) {
bool a[9];
// printf("%d geldi\n", X[0]);
for(int i=0; i<9; i++) a[i] = false;
int msg = X[0];
for(int i= 7; i>-1; i--) {
if(msg>=pow(2,i)) {
a[i] = true;
// printf("%d varmis\n", (int)pow(2,i));
msg-=pow(2,i);
}
}
for(int i=0 ;i<8; i++) a[i]?output(1):output(0);
}
/* for(i=0; i<L; i++) {
b = X[i];
output(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... |