제출 #1332612

#제출 시각아이디문제언어결과실행 시간메모리
1332612QuocSensei앵무새 (IOI11_parrots)C++20
0 / 100
2 ms836 KiB
#include <bits/stdc++.h>

#define ENCODER
// #define DECODER

#define ll long long 
#define el cout << endl
#define bit(mask, i) (((mask) >> (i)) & 1)
#define BIT(n) ((1ll) << (n))
#define ii pair<int, int>
#define fi first 
#define se second

using namespace std;

const int maxlog = 8;
const int maxa = 256;

void send(int a);
void output(int b);

namespace SUBTASK_1
{
    #ifdef ENCODER
    namespace personA
    {
        void encode(int N, int M[])
        {
            int a = 0;
            for (int i = 0; i < N; i++)
                a += M[i] * BIT(i);
            send(a);
        }
    }
    #endif

    #ifdef DECODER
    namespace personB
    {
        void decode(int N, int L, int X[])
        {
            for (int i = 0; i < N; i++)
                output(bit(X[0], i));
        }
    }
    #endif
}
namespace SUBTASK_2
{
    #ifdef ENCODER
    namespace personA
    {
        void encode(int N, int M[])
        {
            for (int i = 0; i < N; i++)
                send(i * 256 + M[i]);
        }
    }
    #endif

    #ifdef DECODER
    namespace personB
    {
        void decode(int N, int L, int X[])
        {
            vector<ii> pr;
            for (int i = 0; i < L; i++)
                pr.push_back(ii(X[i] / 256, X[i] % 256));
            sort(pr.begin(), pr.end());
            for (int i = 0; i < N; i++)
                output(pr[i].se);
        }
    }
    #endif
}
namespace SUBTASK_34
{
    #ifdef ENCODER
    namespace personA
    {
        void encode(int N, int M[])
        {
            int block_size = maxa / N;
            for (int i = 0; i < N; i++)
            {
                for (int j = 0; j < maxlog; j++)
                    if (bit(M[i], j))
                        send(i * block_size + j);
            }
        }
    }
    #endif

    #ifdef DECODER
    namespace personB
    {
        void decode(int N, int L, int X[])
        {
            vector<ii> pr;
            int block_size = maxa / N;
            for (int i = 0; i < L; i++)
                pr.push_back(ii(X[i] / block_size, X[i] % block_size));
            sort(pr.begin(), pr.end());
            for (int i = 0, j = 0; i < N; i++)
            {
                int ans = 0;
                for (; pr[j].fi == i; j++)
                    ans += BIT(pr[j].se);
                output(ans);
            }
        }
    }
    #endif
}

#ifdef ENCODER
void encode(int N, int M[])
{
    SUBTASK_34::personA::encode(N, M);
}
#endif
#ifdef DECODER
void decode(int N, int L, int X[])
{
    SUBTASK_34::personB::decode(N, L, X);
}
#endif
#include <bits/stdc++.h>

// #define ENCODER
#define DECODER

#define ll long long 
#define el cout << endl
#define bit(mask, i) (((mask) >> (i)) & 1)
#define BIT(n) ((1ll) << (n))
#define ii pair<int, int>
#define fi first 
#define se second

using namespace std;

const int maxlog = 8;
const int maxa = 256;

void send(int a);
void output(int b);

namespace SUBTASK_1
{
    #ifdef ENCODER
    namespace personA
    {
        void encode(int N, int M[])
        {
            int a = 0;
            for (int i = 0; i < N; i++)
                a += M[i] * BIT(i);
            send(a);
        }
    }
    #endif

    #ifdef DECODER
    namespace personB
    {
        void decode(int N, int L, int X[])
        {
            for (int i = 0; i < N; i++)
                output(bit(X[0], i));
        }
    }
    #endif
}
namespace SUBTASK_2
{
    #ifdef ENCODER
    namespace personA
    {
        void encode(int N, int M[])
        {
            for (int i = 0; i < N; i++)
                send(i * 256 + M[i]);
        }
    }
    #endif

    #ifdef DECODER
    namespace personB
    {
        void decode(int N, int L, int X[])
        {
            vector<ii> pr;
            for (int i = 0; i < L; i++)
                pr.push_back(ii(X[i] / 256, X[i] % 256));
            sort(pr.begin(), pr.end());
            for (int i = 0; i < N; i++)
                output(pr[i].se);
        }
    }
    #endif
}
namespace SUBTASK_34
{
    #ifdef ENCODER
    namespace personA
    {
        void encode(int N, int M[])
        {
            int block_size = maxa / N;
            for (int i = 0; i < N; i++)
            {
                for (int j = 0; j < maxlog; j++)
                    if (bit(M[i], j))
                        send(i * block_size + j);
            }
        }
    }
    #endif

    #ifdef DECODER
    namespace personB
    {
        void decode(int N, int L, int X[])
        {
            vector<ii> pr;
            int block_size = maxa / N;
            for (int i = 0; i < L; i++)
                pr.push_back(ii(X[i] / block_size, X[i] % block_size));
            sort(pr.begin(), pr.end());
            for (int i = 0, j = 0; i < N; i++)
            {
                int ans = 0;
                for (; pr[j].fi == i; j++)
                    ans += BIT(pr[j].se);
                output(ans);
            }
        }
    }
    #endif
}

#ifdef ENCODER
void encode(int N, int M[])
{
    SUBTASK_34::personA::encode(N, M);
}
#endif
#ifdef DECODER
void decode(int N, int L, int X[])
{
    SUBTASK_34::personB::decode(N, L, X);
}
#endif
#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...