Submission #769840

#TimeUsernameProblemLanguageResultExecution timeMemory
769840teamariaaParrots (IOI11_parrots)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>
#include "encoder.h"

using namespace std;

/// ratio 6N +  8(flaguri)
void encode(int n, int m[])
{
    bitset <256> code;

    for(int i = 0; i < 8 * n; i ++)
        code[i] = 0;
    int j = 7;
    for(int i = 0; i < n; i ++, j += 8)
    {
        while(m[i])
        {
            code[j] = m[i] % 2;
            m[i] >>= 1;
        }
    }

    int cnt1 = 0, cnt0 = 0, flag = 0;
    for(int i = 0; i < 4 * n; i ++)
    {
        if(m[i] == 1)
            cnt1 ++;
        else
            cnt0 ++;
    }

    if(cnt1 <= cnt0)
    {
        flag = 1;
        send(1);
        send(1);
        send(1);
        send(1);
    }

    for(int i = 0; i < 4 * n; i ++)
    {
        if(code[i] == flag)
            send(i);
    }

///////////////////////////////////

    cnt1 = 0, cnt0 = 0;

    for(int i = 4 * n; i < 8 * n; i ++)
    {
        if(m[i] == 1)
            cnt1 ++;
        else
            cnt0 ++;
    }

    if(cnt1 <= cnt0)
    {
        flag = 1;
        send(0);
        send(0);
        send(0);
        send(0);
    }

    for(int i = 4 * n; i < 8 * n; i ++)
    {
        if(code[i] == flag)
        {
            send(i - 255);
            send(i - 255);
        }
    }
}
#include <bits/stdc++.h>
#include "decoder.h"

using namespace std;

void decode(int n, int l, int x[])
{
    bitset <256> code;

    for(int i = 0; i < 8 * n; i ++)
        code[i] = 0;

    sort(x, x + l);

    int cnt, flag1 = 0, flag2 = 0;

    cnt = 1, i = 0;

    if(x[i] == 0)
    {
        while(i < l  &&  x[i] == x[i + 1])
        {
            i ++;
            cnt ++;
        }

        if(cnt >= 4)
            flag2 = 1;
        i ++;
    }

    if(x[i] == 1)
    {
        while(i < l  &&  x[i] == x[i + 1])
        {
            i ++;
            cnt ++;
        }

        if(cnt >= 4)
            flag1 = 1;
        i ++;
    }

    for(int i = 0; i < 4 * n; i ++)
        code[i] = flag1;
    for(int i = 4 * n; i < 8 * n; i ++)
        code[i] = flag2;

    i = 0;
    for(int i = 0; i < l; i ++)
    {
        cnt = 1;
        while(i < l  &&  x[i] == x[i + 1])
        {
            i ++;
            cnt ++;
        }

        if((x[i] == 0  ||  x[i] == 1)  &&  cnt >= 4)
                cnt -=4;
                
        if(cnt == 1  ||  cnt == 3)
            code[x[i]] = flag1;
        if(cnt == 2  ||  cnt == 3)
            code[x[i]] = flag2;
    }
    
    for(int i = 7; i < 8 * ; i ++)
    {
        int pow = 1, nr = 0;
        for(int j = 0; j <= 7; j ++, pow <<= 1)
            nr += code[i - j] * pow;
        output(nr);
    }
}

Compilation message (stderr)

encoder.cpp: In function 'void encode(int, int*)':
encoder.cpp:35:9: error: 'send' was not declared in this scope
   35 |         send(1);
      |         ^~~~
encoder.cpp:44:13: error: 'send' was not declared in this scope
   44 |             send(i);
      |             ^~~~
encoder.cpp:62:9: error: 'send' was not declared in this scope
   62 |         send(0);
      |         ^~~~
encoder.cpp:72:13: error: 'send' was not declared in this scope
   72 |             send(i - 255);
      |             ^~~~

decoder.cpp: In function 'void decode(int, int, int*)':
decoder.cpp:17:14: error: 'i' was not declared in this scope
   17 |     cnt = 1, i = 0;
      |              ^
decoder.cpp:69:28: error: expected primary-expression before ';' token
   69 |     for(int i = 7; i < 8 * ; i ++)
      |                            ^
decoder.cpp:74:9: error: 'output' was not declared in this scope
   74 |         output(nr);
      |         ^~~~~~