Submission #584064

# Submission time Handle Problem Language Result Execution time Memory
584064 2022-06-26T18:24:55 Z AndrejSh3 Parrots (IOI11_parrots) C++17
81 / 100
3 ms 1084 KB
#include<bits/stdc++.h> 
#include"encoder.h"
#include"encoderlib.h"
using namespace std;

/*
	Strategy:
	*) Encoder:
		Encoder will send the following number: xxxxxyyz
			xxxxx is the index of the number in the original message
			yy is which quarter of the message we're sending (33221100)
			z is true if the left bit of this quarter is 1, otherwise the right bit of this quarter is 1
		This encoder will send at most 8*N messages of length 8

	*) Decoder:
		Decoder will take the given numbers xxxxxyyz and create an array with the original message
*/

void sendValue( int i, int q, int Mi ){
	int rv = i;
	rv <<= 2;
	rv |= q;
	rv <<= 1;
	int _Mi = 0;
	if( q == 0 ) _Mi |= ( ( Mi & (1<<1) ) | ( Mi & (1<<0) ) ) >> 0;
	if( q == 1 ) _Mi |= ( ( Mi & (1<<3) ) | ( Mi & (1<<2) ) ) >> 2;
	if( q == 2 ) _Mi |= ( ( Mi & (1<<5) ) | ( Mi & (1<<4) ) ) >> 4;
	if( q == 3 ) _Mi |= ( ( Mi & (1<<7) ) | ( Mi & (1<<6) ) ) >> 6;
	if( _Mi & 1 ) send( rv | 0 );
	if( _Mi & 2 ) send( rv | 1 );
}

void encode( int N, int M[] ){

	for( int i = 0 ; i < N ; i++ ){
		for( int q = 0 ; q < 4 ; q++ ) sendValue( i, q, M[i] );
	}
	
}
#include<bits/stdc++.h>
#include"decoder.h"
#include"decoderlib.h"
using namespace std;

/*
	Strategy:
	*) Encoder:
		Encoder will send the following number: xxxxxyyz
			xxxxx is the index of the number in the original message
			yy is which quarter of the message we're sending (33221100)
			z is true if the left bit of this quarter is 1, otherwise the right bit of this quarter is 1
		This encoder will send at most 8*N messages of length 8

	*) Decoder:
		Decoder will take the given numbers xxxxxyyz and create an array with the original message
*/

void recieveValue( int Xi, int &x, int &y, int &z ){
	z = Xi & (0b1);
	Xi >>= 1;
	y = Xi & (0b11);
	Xi >>= 2;
	x = Xi;
}

void decode( int N, int L, int X[] ){

	int A[N]; for( int &i : A ) i = 0;

	int x, y, z;
	for( int i = 0 ; i < L ; i++ ){
		recieveValue( X[i], x, y, z );
		A[x] |= ( ( z ? 0b10 : 0b01 ) ) << (2*y);
	}

	for( int i = 0 ; i < N ; i++ ) output(A[i]);

}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 608 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1004 KB Output is correct
2 Correct 2 ms 1008 KB Output is correct
3 Correct 2 ms 1036 KB Output is correct
4 Correct 3 ms 1048 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1040 KB Output is correct
2 Correct 2 ms 1036 KB Output is correct
3 Correct 2 ms 1036 KB Output is correct
4 Correct 2 ms 1052 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1032 KB Output is correct
2 Correct 2 ms 1040 KB Output is correct
3 Correct 3 ms 1044 KB Output is correct
4 Correct 3 ms 1056 KB Output is correct
5 Correct 3 ms 1068 KB Output is correct
6 Correct 3 ms 1060 KB Output is correct
# Verdict Execution time Memory Grader output
1 Partially correct 2 ms 1040 KB Output is partially correct - P = 8.000000
2 Partially correct 3 ms 1084 KB Output is partially correct - P = 8.000000
3 Incorrect 1 ms 656 KB Error : Bad encoded integer
4 Incorrect 1 ms 652 KB Error : Bad encoded integer
5 Incorrect 1 ms 652 KB Error : Bad encoded integer
6 Incorrect 1 ms 660 KB Error : Bad encoded integer
7 Incorrect 0 ms 652 KB Error : Bad encoded integer