제출 #387425

#제출 시각아이디문제언어결과실행 시간메모리
387425Aldas25앵무새 (IOI11_parrots)C++14
52 / 100
4 ms1336 KiB
#include "encoder.h"
#include "encoderlib.h"
#include <bits/stdc++.h>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define REP(n) FOR(O, 1, (n))
#define pb push_back
#define f first
#define s second

void encode(int N, int M[])
{
    vector<pair<int, int>> toSend;

    int cnt = 0;
    FOR(i, 0, N-1) {
        int le = M[i];
        vector<int> toAdd;
        REP(4) {
            int a = le % (1<<2);
            //cerr << " i = " << i << " a = " << a << endl;
            toAdd.pb(a);
            le >>= 2;
        }
        reverse(toAdd.begin(), toAdd.end());
        for (int x : toAdd)
            toSend.pb({cnt++, x});
    }

    for (auto p : toSend) {
        send((p.f<<2) + p.s);
    }
    //for(i=0; i<N; i++)
      //  send(M[i]);
}
#include "decoder.h"
#include "decoderlib.h"
#include <bits/stdc++.h>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define REP(n) FOR(O, 1, (n))
#define pb push_back
#define f first
#define s second

void decode(int N, int L, int X[])
{
    vector<pair<int, int>> seq;
    FOR(i, 0, L-1) {
        int a = X[i] >> 2;
        int b = X[i] - (a<<2);
        seq.pb({a,b});
    }

    sort(seq.begin(), seq.end());

    int cur =0;
    FOR(i, 0, N-1) {
        int rez = 0;
        REP(4) {
            rez <<= 2;
            rez +=seq[cur].s;
            cur++;
        }
        output(rez);
    }
}
#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...