Submission #1235299

#TimeUsernameProblemLanguageResultExecution timeMemory
1235299pcp앵무새 (IOI11_parrots)C++20
81 / 100
3 ms840 KiB
#include "encoder.h"
#include "encoderlib.h"
#include <math.h>
#include <iostream>
#include <vector>

using namespace std;



void encode(int N, int M[])
{
  int i;
  for(i=0; i<N-1; i++){
    int b = M[i];
    for (int j = 7;j >= 0;--j){
      int x = pow(2,j);
      if (x <= b){
        b-=x;
        send(j + i*8);
      }
    }

  }

  send(M[N-1]);
  send(M[N-1]);
  send(M[N-1]);
  send(M[N-1]);
  send(M[N-1]);
  
    
}
#include "decoder.h"
#include "decoderlib.h"
#include <math.h>
#include <iostream>
#include <vector>
#include <cstring>


using namespace std;

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

  vector<int> msg(N,0);

  short int stuff[256];
  memset(stuff, 0, sizeof stuff);

  for(i=0; i<L; i++) {
    b = X[i] ;
    stuff[b]+=1;
  }




  for (int i= 0; i<=255;++i ){

    if (stuff[i] >= 5 ){
      stuff[i]-=5;
      msg[N-1] = i;
    }


  }


  for(int b= 0; b<=255;++b) {
    int f=pow(2,(b%8)) * stuff[b];
    msg[b/8] += f;

  }


  for (int c : msg)output(c);
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...