#include "encoder.h"
#include "encoderlib.h"
#include <bits/stdc++.h>
using namespace std;
void encode(int n, int m[]){
if(n>=16) for(int i=0; i<(int)(1.7*n); i++) send(255);
mt19937 rng(177013);
int t=n*8,cnt=0;
for(int i=0; i<n; i++){
for(int j=7; j>=0; j--){
if(m[i]>>j&1) cnt++;
}
}
int num=0,x=0;
if(cnt==t/2){
while(true){
num++;
x=rng()%t;
if(m[x/8]>>(x%8)&1){
m[x/8]^=1<<(x%8);
for(int i=0; i<num+1; i++) send(255);
break;
}
}
}
int prev=0;
if(cnt<=t/2){
for(int i=0; i<n; i++){
for(int j=0; j<8; j++){
if(m[i]>>j&1){
prev++;
send(prev);
}
else send(prev);
}
}
}
else{
for(int i=0; i<n; i++){
for(int j=0; j<8; j++){
if(!(m[i]>>j&1)){
prev++;
send(prev);
}
else send(prev);
}
}
send(255);
}
if(num) m[x/8]^=1<<(x%8);
}
#include "decoder.h"
#include "decoderlib.h"
#include <bits/stdc++.h>
using namespace std;
void decode(int n, int l, int x[]){
sort(x,x+l);
assert(l>=8*n);
mt19937 rng(177013);
if(n>=16) l-=(int)(1.7*n);
int bits[8*n],ex=l-8*n;
if(ex==1){
int prev=0;
for(int i=0; i<8*n; i++){
bits[i]=x[i]-prev;
prev=x[i];
bits[i]^=1;
}
}
else{
int prev=0;
for(int i=0; i<8*n; i++){
bits[i]=x[i]-prev;
prev=x[i];
}
if(ex>0){
int y=0;
for(int i=0; i<ex-1; i++) y=rng()%(8*n);
//cout << y << ' ';
bits[y]^=1;
}
}
for(int i=0; i<n; i++){
int ret=0;
for(int j=0; j<8; j++){
ret+=bits[i*8+j]<<j;
}
output(ret);
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
792 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
1316 KB |
Output is correct |
2 |
Correct |
2 ms |
1320 KB |
Output is correct |
3 |
Correct |
3 ms |
1324 KB |
Output is correct |
4 |
Correct |
4 ms |
1320 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
1300 KB |
Output is correct |
2 |
Correct |
2 ms |
1316 KB |
Output is correct |
3 |
Correct |
3 ms |
1328 KB |
Output is correct |
4 |
Correct |
3 ms |
1324 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
1308 KB |
Output is correct |
2 |
Incorrect |
1 ms |
784 KB |
Error : Encoded message too long |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Partially correct |
4 ms |
1376 KB |
Output is partially correct - P = 9.812500 |
2 |
Partially correct |
8 ms |
1348 KB |
Output is partially correct - P = 9.906250 |
3 |
Partially correct |
6 ms |
1360 KB |
Output is partially correct - P = 9.727273 |
4 |
Partially correct |
9 ms |
1384 KB |
Output is partially correct - P = 9.740000 |
5 |
Partially correct |
13 ms |
1420 KB |
Output is partially correct - P = 9.733333 |
6 |
Partially correct |
12 ms |
1628 KB |
Output is partially correct - P = 9.809524 |
7 |
Partially correct |
12 ms |
1412 KB |
Output is partially correct - P = 9.718750 |