# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
358398 | Ahmad_Hasan | Data Transfer (IOI19_transfer) | C++17 | 15 ms | 2772 KiB |
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;
vector<int> get_attachment(vector<int>src){
if(src.size()<=15){
int n=src.size();
for(int i=0;i<n;i++)src.push_back(src[i]);
return src;
}
long long p=31;
long long mod=1e9+7;
long long ppow=1ll;
long long hsh=0ll;
int n=src.size();
for(int i=0;i<n;i++){
hsh+=src[i]*ppow;
hsh%=mod;
ppow*=p;
ppow%=mod;
}
vector<int>ret(30);
for(int i=0;i<30;i++)ret[i]=!!(hsh&(1<<i));
return ret;
}
vector<int> retrieve(vector<int>data){
vector<int>ret;
if(data.size()<=60){
int n=data.size();
for(int i=0;i<n/3;i++){
ret.push_back(((data[i]+data[n/3+i]+data[2*n/3+i])>=2)?1:0);
}
}else{
long long p=31;
long long mod=1e9+7;
long long ppow=1ll;
long long hsh=0ll;
int n=data.size()-30;
vector<int>ret;
for(int i=0;i<n;i++){
hsh+=data[i]*ppow;
hsh%=mod;
ppow*=p;
ppow%=mod;
}
int f=0;
for(int i=n;i<data.size();i++){
if(data[i]!=!!(hsh&(1<<(i-n))))
f=1;
}
if(!f){
for(int i=0;i<n;i++){
ret.push_back(data[i]);
}
return ret;
}
for(int i=0;i<n;i++){
data[i]=!data[i];
p=31;
mod=1e9+7;
ppow=1ll;
hsh=0ll;
for(int i=0;i<n;i++){
hsh+=data[i]*ppow;
hsh%=mod;
ppow*=p;
ppow%=mod;
}
int f=0;
for(int i=n;i<data.size();i++){
if(data[i]!=!!(hsh&(1<<(i-n))))
f=1;
}
if(!f){
for(int i=0;i<n;i++){
ret.push_back(data[i]);
}
return ret;
}
data[i]=!data[i];
}
for(int i=0;i<n;i++){
ret.push_back(data[i]);
}
return ret;
}
return ret;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |