Submission #1051847

#TimeUsernameProblemLanguageResultExecution timeMemory
1051847Szymon_PilipczukParrots (IOI11_parrots)C++17
81 / 100
4 ms1348 KiB
#include "encoder.h"
#include "encoderlib.h"
using namespace std;
void encode(int N, int M[])
{
  int i;
  for(i=0; i<N; i++)
  {
    send(i*8+M[i]/64);
    for(int j = 0;j<2;j++)
    {
        send(i*8+M[i]/8-M[i]/64*8);
    }
    for(int j = 0;j<4;j++)
    {
        send(i*8+M[i]-M[i]/8*8);
    }

  }
}

#include "decoder.h"
#include "decoderlib.h"
#include <algorithm>
using namespace std;
void decode(int N, int L, int X[])
{
    sort(X,X+L);
    for (int i = 0;i<N;i++)
    {
        int answer = 0;
        int countt = 0;
        for(int j = 0;j<7;j++)
        {
            countt++;
            if (i*7+j<L-1)
            {
                if (X[i*7+j] != X[i*7+j+1])
                {
                    if (countt%2 ==1)
                    {
                        answer+=X[i*7+j]%8*64;
                    }
                    if (countt%4 == 2 or countt%4 == 3)
                    {
                        answer+=X[i*7+j]%8*8;
                    }
                    if (countt>=4)
                    {
                        answer+=X[i*7+j]%8;
                    }
                    countt = 0;
                }
            }
            else
            {
                if (countt%2 ==1)
                {
                    answer+=X[i*7+j]%8*64;
                }
                if (countt%4 == 2 or countt%4 == 3)
                {
                    answer+=X[i*7+j]%8*8;
                }
                if (countt>=4)
                {
                    answer+=X[i*7+j]%8;
                }
                countt = 0;
            }


        }
        output(answer);
    }
}
#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...