Submission #767026

#TimeUsernameProblemLanguageResultExecution timeMemory
767026raysh07Parrots (IOI11_parrots)C++17
81 / 100
3 ms1064 KiB
#include "encoder.h"
#include "encoderlib.h"
#include <bits/stdc++.h>
using namespace std;

void encode(int n, int a[])
{
//   int i;
//   for(i=0; i<N; i++)
//     send(M[i]);
    if (n <= 32){
        for (int i = 0; i < n; i++){
            for (int j = 0; j < 8; j++){
                if (a[i] >> j & 1){
                    send(8 * i + j);
                }
            }
        }
    }
}
#include "decoder.h"
#include "decoderlib.h"
#include <bits/stdc++.h>
using namespace std;

void decode(int n, int l, int a[])
{
    //l is length of encoded sequence
    //n is the answer we need 
    vector <int> cnt(256, 0);
    for (int i = 0; i < l; i++) cnt[a[i]]++;
    
    // for (int i = 0; i < 256; i++){
    //     if (cnt[i] > 0) {
    //         cout << cnt[i] << " " << i << "\n";
    //     }
    // }
    if (n <= 32){
        vector <int> ans(n, 0);
        for (int i = 0; i < 256; i++){
            if (cnt[i] == 1){
                ans[i / 8] += 1 << (i % 8);
            }
        }
        
        for (int i = 0; i < n; i++){
           // cout << ans[i] <<
            output(ans[i]);
        }
    }
}
#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...