#include "encoder.h"
#include "encoderlib.h"
#include<bits/stdc++.h>
using namespace std;
string add(string a, string b){
if(a.size() > b.size()){
swap(a, b);
}
a = string(int(b.size()) - int(a.size()), '0') + a;
string ans = "";
int carry = 0;
for(int i = int(a.size()) - 1; i > -1; i--){
int sum = a[i] + b[i] - 96 + carry;
if(sum > 9){
sum -= 10;
carry = 1;
}
else{
carry = 0;
}
ans += char(sum + 48);
}
if(carry == 1){
ans += '1';
}
while(ans.size() > 1 && ans.back() == '0'){
ans.pop_back();
}
return ans;
}
string sub(string a, string b){
b = string(int(a.size()) - int(b.size()), '0') + b;
string ans = "";
int carry = 0;
for(int i = int(a.size()) - 1; i > -1; i--){
int d = a[i] - b[i] - carry;
if(d < 0){
d += 10;
carry = 1;
}
else{
carry = 0;
}
ans += char(d + 48);
}
while(ans.size() > 1 && ans.back() == '0'){
ans.pop_back();
}
return ans;
}
string mul(string a, int b){
string ans = "0";
for(int i = int(a.size()) - 1; i > -1; i--){
ans = add(ans, to_string((a[i] - 48) * b) + string(int(a.size()) - i - 1, '0'));
}
return ans;
}
bool is_smaller(string a, string b){
if(a.size() != b.size()){
return a.size() < b.size();
}
for(int i = 0; i < a.size(); i++){
if(a[i] != b[i]){
return a[i] < b[i];
}
}
return false;
}
const int lim = 580;
string pw_256[lim], Ckn[lim][lim];
void encode(int N, int M[]){
for(int i = 0; i < lim; i++){
Ckn[0][i] = "1";
for(int j = 1; j <= i; j++){
Ckn[j][i] = add(Ckn[j - 1][i], Ckn[j - 1][i - 1]);
}
for(int j = i + 1; j < lim; j++){
Ckn[j][i] = "0";
}
}
pw_256[0] = "1";
for(int i = 1; i < lim; i++){
pw_256[i] = mul(pw_256[i - 1], 256);
cout << i << " " << pw_256[i] << endl;
}
if(N <= 32){
for(int i = 0; i < N; i++){
for(int j = 0; j < 8; j++){
if(1 << j & M[i]){
send((i << 3) + j);
}
}
}
return;
}
}
#include "decoder.h"
#include "decoderlib.h"
#include<bits/stdc++.h>
using namespace std;
//string add(string a, string b){
// if(a.size() > b.size()){
// swap(a, b);
// }
// a = string(int(b.size()) - int(a.size()), '0') + a;
// string ans = "";
// int carry = 0;
// for(int i = int(a.size()) - 1; i > -1; i--){
// int sum = a[i] + b[i] - 96 + carry;
// if(sum > 9){
// sum -= 10;
// carry = 1;
// }
// else{
// carry = 0;
// }
// ans += char(sum + 48);
// }
// if(carry == 1){
// ans += '1';
// }
// while(ans.size() > 1 && ans.back() == '0'){
// ans.pop_back();
// }
// return ans;
//}
//string sub(string a, string b){
// b = string(int(a.size()) - int(b.size()), '0') + b;
// string ans = "";
// int carry = 0;
// for(int i = int(a.size()) - 1; i > -1; i--){
// int d = a[i] - b[i] - carry;
// if(d < 0){
// d += 10;
// carry = 1;
// }
// else{
// carry = 0;
// }
// ans += char(d + 48);
// }
// while(ans.size() > 1 && ans.back() == '0'){
// ans.pop_back();
// }
// return ans;
//}
//string mul(string a, int b){
// string ans = "0";
// for(int i = int(a.size()) - 1; i > -1; i--){
// ans = add(ans, to_string((a[i] - 48) * b) + string(int(a.size()) - i - 1, '0'));
// }
// return ans;
//}
//bool is_smaller(string a, string b){
// if(a.size() != b.size()){
// return a.size() < b.size();
// }
// for(int i = 0; i < a.size(); i++){
// if(a[i] != b[i]){
// return a[i] < b[i];
// }
// }
// return false;
//}
void decode(int N, int L, int X[]){
if(N <= 32){
vector<bool>bit(N << 3, false);
for(int i = 0; i < L; i++){
bit[X[i]] = true;
}
for(int i = 0; i < N; i++){
int ans = 0;
for(int j = 0; j < 8; j++){
if(bit[(i << 3) + j]){
ans |= 1 << j;
}
}
output(ans);
}
return;
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |