Submission #771298

#TimeUsernameProblemLanguageResultExecution timeMemory
771298iulia13Parrots (IOI11_parrots)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>
#include "encoder.h"
#include "encoderlib.h"
using namespace std;
const int N = 513;
void encode(int n, int a[])
{
    int cnt = 0, i = 0, ok = 0, tot = 3 * 128;
    while (cnt <= 248 && i < n)
    {
        int nr = 128;
        while(nr)
        {
            if (a[i] & nr)
                ok++;
            nr /= 2;
            cnt++;
        }
        i++;
    }
    while (cnt <= 504 && i < n)
    {
        int nr = 128;
        while (nr)
        {
            if (a[i] & nr)
            {
                ok += 2;
                //send(cnt - 256);
                //send(cnt - 256);
            }
            nr /= 2;
            cnt++;
        }
        i++;
    }
    if (ok <= tot)
        ok = 1;
    else
        ok = 0;

    cnt = i = 0;
    while (cnt <= 248 && i < n)
    {
        int nr = 128;
        while(nr)
        {
            if ((a[i] & nr) == nr * ok)
                send(cnt);
            nr /= 2;
            cnt++;
        }
        i++;
    }
    while (cnt <= 504 && i < n)
    {
        int nr = 128;
        while (nr)
        {
            if ((a[i] & nr) == nr * ok)
            {
                send(cnt - 256);
                send(cnt - 256);
            }
            nr /= 2;
            cnt++;
        }
        i++;
    }
    if (!ok)
    {
        send(0);
        send(0);
        send(0);
        send(0);
    }
  	return;
}
#include <bits/stdc++.h>
#include "decoder.h"
#include "decoderlib.h"
 
using namespace std;
int vf[N];
int ans[N];
int bits[N];
void decode(int n, int l, int a[])
{
    for (int i = 0; i < l; i++)
    {
        vf[a[i]]++;
    }
    if (vf[0] >= 4)
    {
        for (int i = 0; i < n; i++)
            bits[i] = 1;
    }
    for (int i = 0; i < 256; i++)
    {
        if (vf[i] & 1)
            bits[i] |= 1;
        if (vf[i] & 2)
            bits[i] |= 1;
    }
    int j = 0;
    for (int i = 0; i < n; i++)
    {
        int nr = 128;
        while (nr)
        {
            ans[i] += bits[j] * nr;
            nr /= 2;
            j++;
        }
        output(ans[i]);
    }
  	return;
}

Compilation message (stderr)

decoder.cpp:6:8: error: 'N' was not declared in this scope
    6 | int vf[N];
      |        ^
decoder.cpp:7:9: error: 'N' was not declared in this scope
    7 | int ans[N];
      |         ^
decoder.cpp:8:10: error: 'N' was not declared in this scope
    8 | int bits[N];
      |          ^
decoder.cpp: In function 'void decode(int, int, int*)':
decoder.cpp:13:9: error: 'vf' was not declared in this scope
   13 |         vf[a[i]]++;
      |         ^~
decoder.cpp:15:9: error: 'vf' was not declared in this scope
   15 |     if (vf[0] >= 4)
      |         ^~
decoder.cpp:18:13: error: 'bits' was not declared in this scope
   18 |             bits[i] = 1;
      |             ^~~~
decoder.cpp:22:13: error: 'vf' was not declared in this scope
   22 |         if (vf[i] & 1)
      |             ^~
decoder.cpp:23:13: error: 'bits' was not declared in this scope
   23 |             bits[i] |= 1;
      |             ^~~~
decoder.cpp:24:13: error: 'vf' was not declared in this scope
   24 |         if (vf[i] & 2)
      |             ^~
decoder.cpp:25:13: error: 'bits' was not declared in this scope
   25 |             bits[i] |= 1;
      |             ^~~~
decoder.cpp:33:13: error: 'ans' was not declared in this scope; did you mean 'abs'?
   33 |             ans[i] += bits[j] * nr;
      |             ^~~
      |             abs
decoder.cpp:33:23: error: 'bits' was not declared in this scope
   33 |             ans[i] += bits[j] * nr;
      |                       ^~~~
decoder.cpp:37:16: error: 'ans' was not declared in this scope; did you mean 'abs'?
   37 |         output(ans[i]);
      |                ^~~
      |                abs