Submission #580648

#TimeUsernameProblemLanguageResultExecution timeMemory
580648MohamedFaresNebiliParrots (IOI11_parrots)C++14
88 / 100
9 ms1356 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 encode(int N, int M[]) {
            bitset<520> B;
            for(int l = 0; l < N; l++) {
                int V = M[l];
                for(int i = 0; i < 8; i++)
                    B[l * 8 + i] = (V & (1 << i));
            }
            for(int l = 0; l < N * 8; l++) {
                if(B[l]) {
                    if(l >= 256)
                        send(l - 256), send(l - 256);
                    else send(l);
                }
            }
        }
#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[]) {
            sort(X, X + L);
            bitset<520> B; int occ[256];
            memset(occ, 0, sizeof occ);
            for(int l = 0; l < L; l++) occ[X[l]]++;
            for(int l = 0; l < 256; l++) {
                if(occ[l] == 1 || occ[l] == 3) B[l] = 1;
                if(occ[l] == 2 || occ[l] == 3) B[l + 256] = 1;
            }
            for(int l = 0; l < N; l++) {
                int K = 0;
                for(int i = 0; i < 8; i++)
                    if(B[l * 8 + 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...