Submission #935202

# Submission time Handle Problem Language Result Execution time Memory
935202 2024-02-28T19:37:37 Z KebabuVaikis15 Parrots (IOI11_parrots) C++14
0 / 100
7 ms 2468 KB
#include "encoder.h"
#include "encoderlib.h"
#include <bits/stdc++.h>
using namespace std;

static map<int, bool> lank;
static map<int, pair<int, int>> perm;
static int b[7];

static int iSkaiciu()
{
    int s=0;
    for (int i=0; i<7; i++)
        s+=b[i]<<(2*i);
    return s;
}

static void pildyti(int L)
{
    int val=iSkaiciu();
    if (lank.count(val))
        return;
    lank[val]=1;
    perm[perm.size()]={L, val};
    for (int i=0; i<L; i++)
        if ((i==L-1 && b[i]<3) || (i<L-1 && b[i]<b[i+1]))
        {
            b[i]++;
            pildyti(L);
            b[i]--;
        }
}

void encode(int N, int M[])
{
    for (int i=0; i<=7; i++)
    {
        pildyti(i);
        lank.clear();
    }
    for (int i=0; i<N; i++)
        for (int j=0; j<perm[M[i]].first; j++)
        {
            send((i<<2)+((perm[M[i]].second>>(2*j))&3));
//            cout<<((i<<2)+((perm[M[i]].second>>(2*j))&3))<<endl;
        }
}
#include "decoder.h"
#include "decoderlib.h"
#include <bits/stdc++.h>
using namespace std;

static map<int, bool> lank2;
static map<pair<int, int>, int> perm2;
static int b[7];

static int iSkaiciu()
{
    int s=0;
    for (int i=0; i<7; i++)
        s+=b[i]<<(2*i);
    return s;
}

static void pildyti(int L)
{
    int val=iSkaiciu();
    if (lank2.count(val))
        return;
    lank2[val]=1;
    perm2[{L, val}]=perm2.size();
    for (int i=0; i<L; i++)
        if ((i==L-1 && b[i]<3) || (i<L-1 && b[i]<b[i+1]))
        {
            b[i]++;
            pildyti(L);
            b[i]--;
        }
}

void decode(int N, int L, int X[])
{
    vector<int> B[N];
    for (int i=0; i<=7; i++)
    {
        pildyti(i);
        lank2.clear();
    }
    for (int i=0; i<L; i++)
        B[X[i]>>2].push_back(X[i]&3);
    for (int i=0; i<N; i++)
    {
        sort(B[i].begin(), B[i].end());
        int s=0;
        for (int j=0; j<B[i].size(); j++)
            s+=B[i][j]<<(2*j);
        output(perm2[{B[i].size(), s}]);
    }
}

Compilation message

decoder.cpp: In function 'void decode(int, int, int*)':
decoder.cpp:48:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   48 |         for (int j=0; j<B[i].size(); j++)
      |                       ~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 1040 KB Error : Output is wrong
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 2336 KB Error : Output is wrong
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 2340 KB Error : Output is wrong
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 7 ms 2468 KB Error : Output is wrong
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 2340 KB Error : Output is wrong
2 Halted 0 ms 0 KB -