Submission #961396

# Submission time Handle Problem Language Result Execution time Memory
961396 2024-04-12T03:41:17 Z emptypringlescan Parrots (IOI11_parrots) C++17
13.0303 / 100
18 ms 1972 KB
#include "encoder.h"
#include "encoderlib.h"
#include <bits/stdc++.h>
using namespace std;
void encode(int n, int m[]){
	for(int i=0; i<5*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);
	int bits[8*n],ex=l-8*n-5*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);
	}
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 784 KB Error : Encoded message too long
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 784 KB Error : Encoded message too long
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 784 KB Error : Encoded message too long
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 1096 KB Error : Encoded message too long
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Partially correct 4 ms 1332 KB Output is partially correct - P = 13.125000
2 Partially correct 8 ms 1380 KB Output is partially correct - P = 13.218750
3 Partially correct 8 ms 1372 KB Output is partially correct - P = 13.030303
4 Partially correct 13 ms 1676 KB Output is partially correct - P = 13.040000
5 Partially correct 18 ms 1700 KB Output is partially correct - P = 13.033333
6 Partially correct 18 ms 1716 KB Output is partially correct - P = 13.111111
7 Partially correct 17 ms 1972 KB Output is partially correct - P = 13.031250