제출 #580676

#제출 시각아이디문제언어결과실행 시간메모리
580676MohamedFaresNebili앵무새 (IOI11_parrots)C++14
98 / 100
7 ms1364 KiB
#include <bits/stdc++.h>
#include "encoder.h"
#include "encoderlib.h"
#include <ext/pb_ds/assoc_container.hpp>

        using namespace std;
        using namespace __gnu_pbds;

        using ll = long long;
        using ii = pair<int, int>;

        #define pb push_back
        #define pp pop_back
        #define ff first
        #define ss second

        typedef tree<int, null_type, less<int>, rb_tree_tag,
            tree_order_statistics_node_update> indexed_set;

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

        void encode(int N, int M[]) {
            bitset<512> B;
            for(int l = 0; l < N; l++)
                for(int i = 0; i < 8; i++)
                    B[l * 8 + i] = (M[l] & (1 << i));
            int C[4]{0}, F[4]{0};
            for(int l = 0; l < 8 * N; l += 2) {
                C[B[l] * 2 + B[l + 1]]++;
                F[3 - B[l] * 2 - B[l + 1]]++;
            }
            bool ok = 1;
            if(C[1] + 2 * C[2] + 3 * C[3] < F[1] + 2 * F[2] + 3 * F[3])
                ok = 0;
            for(int l = 0; l < 8 * N; l += 2) {
                int V = B[l] * 2 + B[l + 1];
                if(ok) V = 3 - V;
                for(int i = 0; i < V; i++) send(l / 2);
            }
            if(!ok) return;
            for(int l = 0; l < 4; l++) send(255);
        }
#include <bits/stdc++.h>
#include "decoder.h"
#include "decoderlib.h"
#include <ext/pb_ds/assoc_container.hpp>

        using namespace std;
        using namespace __gnu_pbds;

        using ll = long long;
        using ii = pair<int, int>;

        #define pb push_back
        #define pp pop_back
        #define ff first
        #define ss second

        typedef tree<int, null_type, less<int>, rb_tree_tag,
            tree_order_statistics_node_update> indexed_set;

        void decode(int N, int L, int X[]) {
            bitset<520> B; int occ[256];
            memset(occ, 0, sizeof occ);
            for(int l = 0; l < L; l++) occ[X[l]]++;
            bool ok = 0;
            if(occ[255] > 3) ok = 1, occ[255] -= 4;
            for(int l = 0; l < 4 * N; l++) {
                int V = occ[l];
                if(ok) V = 3 - V;
                B[l * 2 + 1] = V & 1;
                B[l * 2] = V & 2;
            }
            for(int l = 0; l < 8 * N; l += 8) {
                int K = 0;
                for(int i = 0; i < 8; i++)
                    if(B[l + i]) K += (1 << i);
                output(K);
            }
        }
#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...