This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "transfer.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int MOD = 68;
std::vector<int> get_attachment(std::vector<int> source) {
int n = (int)source.size();
string bs = "";
for(int i = 0; i < n; ++i ){
if(source[i] == 0) bs += "0";
else bs += "1";
}
ull a = stoull(bs, 0, 2);
int ans = a % MOD;
string md = bitset<7>(ans).to_string();
vector<int> K;
for(int j = 0; j < 2; ++j){
for(int i = 0; i < (int) md.size(); ++i ){
if(md[i] == '0') K.push_back(0);
else K.push_back(1);
}
}
return K;
}
std::vector<int> retrieve(std::vector<int> data) {
int N = (int)data.size();
string BS = "";
for(int i = 0; i < 63; ++i ){
if(data[i] == 0) BS += "0";
else BS += "1";
}
string bs1 = "";
for(int i = 63; i < 70; ++i ){
if(data[i] == 0) bs1 += "0";
else bs1 += "1";
}
string bs2 = "";
for(int i = 70; i < N; ++i ){
if(data[i] == 0) bs2 += "0";
else bs2 += "1";
}
ull res = stoull(BS, 0, 2), check1 = stoull(bs1, 0, 2), check2 = stoull(bs2, 0, 2);
res %= MOD;
if(res == check1 || res == check2){
vector<int> src1;
for(int i = 0; i < 63; ++i ){
if(data[i] == 0) src1.push_back(0);
else src1.push_back(1);
}
return src1;
}
else{
for(int i = 0; i < 63; ++i ){
if(BS[i] == '0') BS[i] = '1';
else BS[i] = '0';
ull check = stoull(BS, 0, 2);
check %= MOD;
if (check == check1 || check == check2){
vector<int> src2;
for(int i = 0; i < 63; ++i ){
if(BS[i] == '0') src2.push_back(0);
else src2.push_back(1);
}
return src2;
}
if(BS[i] == '0') BS[i] = '1';
else BS[i] = '0';
}
}
}
Compilation message (stderr)
transfer.cpp: In function 'std::vector<int> retrieve(std::vector<int>)':
transfer.cpp:75:1: warning: control reaches end of non-void function [-Wreturn-type]
}
^
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |