Submission #710997

# Submission time Handle Problem Language Result Execution time Memory
710997 2023-03-16T06:59:01 Z Darren0724 Data Transfer (IOI19_transfer) C++17
0 / 100
7 ms 2452 KB
#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);
        for(int j=0;j<6;j++){
            for(int i=0;i<n;i++){
                if(i&(1<<j)){
                    a[j]^=source[i];
                }
            }
        }
        for(int i=0;i<n;i++){
            a[6]^=source[i];
        }
        return a;
    }
    else{
        vector<int> a(9);
        for(int j=0;j<8;j++){
            for(int i=0;i<n;i++){
                if(i&(1<<j)){
                    a[j]^=source[i];
                }
            }
        }
        for(int i=0;i<n;i++){
            a[8]^=source[i];
        }
        return a;
    }
}

std::vector<int> retrieve(std::vector<int> data) {
    int n=data.size();
    if(n==70){
        vector<int> a(6),b(6);
        for(int i=63;i<70;i++){
            a[i]=data[i-63];
            b[i]=data[69]^a[i];
        }
        vector<int> a1(6),b1(6);
        for(int j=0;j<6;j++){
            for(int i=0;i<63;i++){
                if(i&(1<<j)){
                    a1[j]^=data[i];
                }
                else{
                    b1[j]^=data[i];
                }
            }
        }
        int ans=0;
        int cnt=0;
        for(int j=0;j<6;j++){
            if(a[j]!=a1[j]){
                cnt++;
                ans^=(1<<j);
            }
            if(b[j]!=b1[j]){
                cnt++;
            }
        }
        //cout<<cnt<<endl;
        vector<int> ans1(63);
        for(int i=0;i<63;i++){
            ans1[i]=data[i];
        }
        if(cnt==6){
            ans1[ans]^=1;
        }
        //cout<<cnt<<' '<<ans<<endl;
        return ans1;
    }
    else{
        vector<int> a(8),b(8);
        for(int i=255;i<264;i++){
            a[i]=data[i-255];
            b[i]=data[263]^a[i];
        }
        vector<int> a1(8),b1(8);
        for(int j=0;j<8;j++){
            for(int i=0;i<255;i++){
                if(i&(1<<j)){
                    a1[j]^=data[i];
                }
                else{
                    b1[j]^=data[i];
                }
            }
        }
        int ans=0;
        int cnt=0;
        for(int j=0;j<8;j++){
            if(a[j]!=a1[j]){
                cnt++;
                ans^=(1<<j);
            }
            if(b[j]!=b1[j]){
                cnt++;
            }
        }
        vector<int> ans1(255);
        for(int i=0;i<255;i++){
            ans1[i]=data[i];
        }
        if(cnt==8){
            ans1[ans]^=1;
        }
        //cout<<ans<<endl;
        return ans1;
    }
}
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 652 KB WA in grader: wrong source retrieval
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 7 ms 2452 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -