#include "transfer.h"
//#include "grader.cpp"
#include <bits/stdc++.h>
using namespace std;
std::vector<int> get_attachment(std::vector<int> source) {
int n=source.size();
if(n==63){
vector<int> a(7),b(7);
for(int j=0;j<6;j++){
for(int i=0;i<n;i++){
if(i&(1<<j)){
b[j]^=source[i];
}
else{
a[j]^=source[i];
}
}
}
for(int i=0;i<n;i++){
a[6]^=source[i];
}
return a;
}
else{
vector<int> a(9),b(9);
for(int j=0;j<8;j++){
for(int i=0;i<n;i++){
if(i&(1<<j)){
b[j]^=source[i];
}
else{
a[j]^=source[i];
}
}
}
for(int i=0;i<n;i++){
a[9]^=source[i];
}
return a;
}
}
std::vector<int> retrieve(std::vector<int> data) {
vector<int> v=data;
int n=v.size();
if(n==70){
vector<int> a(6),b(6);
for(int i=63;i<69;i++){
a[i-63]=v[i];
b[i-63]=v[69]^a[i-63];
}
vector<int> a1(6),b1(6);
for(int j=0;j<6;j++){
for(int i=0;i<63;i++){
if(i&(1<<j)){
b1[j]^=v[i];
}
else{
a1[j]^=v[i];
}
}
}
int ans=0;
int cnt=0;
for(int j=0;j<6;j++){
if(a[j]!=a1[j]){
cnt++;
}
if(b[j]!=b1[j]){
cnt++;
ans^=(1<<j);
}
}
vector<int> ans1(63);
//cout<<cnt<<' '<<ans<<endl;
for(int i=0;i<63;i++){
ans1[i]=v[i];
}
if(cnt==6&&ans!=63){
ans1[ans]^=1;
}
return ans1;
}
else{
vector<int> a(8),b(8);
for(int i=255;i<263;i++){
a[i-255]=v[i];
b[i-255]=v[263]^a[i-255];
}
vector<int> a1(8),b1(8);
for(int j=0;j<8;j++){
for(int i=0;i<255;i++){
if(i&(1<<j)){
b1[j]^=v[i];
}
else{
a1[j]^=v[i];
}
}
}
int ans=0;
int cnt=0;
for(int j=0;j<8;j++){
if(a[j]!=a1[j]){
cnt++;
}
if(b[j]!=b1[j]){
cnt++;
ans^=(1<<j);
}
}
vector<int> ans1(255);
//cout<<cnt<<' '<<ans<<endl;
for(int i=0;i<255;i++){
ans1[i]=v[i];
}
if(cnt==8&&ans!=255){
ans1[ans]^=1;
}
return ans1;
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
648 KB |
Output is correct |
2 |
Correct |
5 ms |
640 KB |
Output is correct |
3 |
Correct |
5 ms |
704 KB |
Output is correct |
4 |
Correct |
4 ms |
640 KB |
Output is correct |
5 |
Correct |
6 ms |
640 KB |
Output is correct |
6 |
Correct |
5 ms |
640 KB |
Output is correct |
7 |
Correct |
7 ms |
652 KB |
Output is correct |
8 |
Correct |
5 ms |
652 KB |
Output is correct |
9 |
Correct |
7 ms |
640 KB |
Output is correct |
10 |
Correct |
5 ms |
640 KB |
Output is correct |
11 |
Correct |
4 ms |
648 KB |
Output is correct |
12 |
Correct |
4 ms |
648 KB |
Output is correct |
13 |
Correct |
7 ms |
640 KB |
Output is correct |
14 |
Correct |
5 ms |
640 KB |
Output is correct |
15 |
Correct |
4 ms |
648 KB |
Output is correct |
16 |
Correct |
5 ms |
640 KB |
Output is correct |
17 |
Correct |
5 ms |
640 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
6 ms |
2492 KB |
WA in grader: wrong source retrieval |
2 |
Halted |
0 ms |
0 KB |
- |