Submission #65862

# Submission time Handle Problem Language Result Execution time Memory
65862 2018-08-09T04:40:41 Z lipschitz Parrots (IOI11_parrots) C++14
Compilation error
0 ms 0 KB
#include "encoder.h"
#include "encoderlib.h"

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

	if (N > 32) {
		int mask = 0x000f;

		for (i = 0; i < N; i++) {
			int seq = i << 2;
			int temp = M[i]&mask;

			for (int j = 0; j < 4; j++) {
				if (temp & 1) {
					send(seq + j);
				}

				temp >>= 1;
			}

			temp = (M[i] >> 4)&mask;

			for (int j = 0; j < 4; j++) {
				if (temp & 1) {
					send(seq + j);
					send(seq + j);
				}

				temp >>= 1;
			}
		}

		return;
	}


  

  for (i = 0; i < N; i++) {
	  int seq = i << 3;
	  int temp = M[i];

	  for (int j = 0; j < 8; j++) {
		  if (temp & 1) {
			  send(seq + j);
		  }

		  temp >>= 1;
	  }
  }
}
#include "decoder.h"
#include "decoderlib.h"
#include<algorithm>

using namespace std;

void decode(int N, int L, int X[])
{
  int i, mask = 0x0007, mask2 = 0x0003;
  int b[64];

  for (int i = 0; i < 64; i++)
	  b[i] = 0;

  sort(X, X + L);
  int seq = 0, ans = 0;

  if (N > 32) {
	  for (i = 0; i < L-1; ) {
		  if ((X[i] >> 2) ^ seq) {
			  b[seq] = ans;
			  ans = 0;
			  seq = X[i] >> 2;
			  continue;
		  }

		  if ((X[i] & mask2)^(X[i+1] & mask2)) {
			  ans += (1 << (X[i] & mask2));
		  }
		  else {
			  ans += ((1 << (X[i] & mask2)) << 4);
			  i++;
		  }

		  i++;
	  }

	  if (i < L) {
		  ans += (1 << (X[L-1] & mask2));
	  }

	  b[seq] = ans;

	  for (int i = 0; i < N; i++) {
		  output(b[i]);
		  printf("%d ", b[i]);
	  }
		  

	  return;
  }


  
  for(i=0; i<L; i++) {
	  if ((X[i] >> 3)^seq) {
		  b[seq] = ans;
		  ans = 0;
		  seq = X[i] >> 3;
	  }

	  ans += (1 << (X[i] & mask));	  
  }

  b[seq] = ans;

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

Compilation message

decoder.cpp: In function 'void decode(int, int, int*)':
decoder.cpp:46:5: error: 'printf' was not declared in this scope
     printf("%d ", b[i]);
     ^~~~~~
decoder.cpp:46:5: note: suggested alternative: 'uint'
     printf("%d ", b[i]);
     ^~~~~~
     uint