# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1187724 | rainmar | Parrots (IOI11_parrots) | C++20 | 0 ms | 0 KiB |
#include "encoder.h"
#include "encoderlib.h"
#include <bits/stdc++.h>
using namespace std;
string intToBinaryString(uint16_t number) {
return bitset<16>(number).to_string();
}
void encode(int N, int M[])
{
string e = "";
uint16_t i, b;
for(i=0; i<N; i++) {
b = M[i];
e += intToBinaryString(b);
}
for (size_t i = 0; i < e.size(); i++) {
if (e[i] == '1') {
send(i);
}
}
}
#include "decoder.h"
#include "decoderlib.h"
#include <bits/stdc++.h>
using namespace std;
string intToBinaryString(int number) {
return bitset<32>(number).to_string();
}
void decode(int N, int L, int X[]) {
string binary(N * 16, '0');
for(int i = 0; i < L; i++) {
binary[X[i]] = '1';
}
for (int i = 0; i < N; i++) {
string byteStr = binary.substr(i * 16, 16);
int value = bitset<16>(byteStr).to_ulong();
send(value);
}
}