Submission #1093601

# Submission time Handle Problem Language Result Execution time Memory
1093601 2024-09-27T06:24:42 Z Irate Data Transfer (IOI19_transfer) C++17
Compilation error
0 ms 0 KB
#include "transfer.h"
using namespace std;
vector<int> get_attachment(vector<int> source) {
    int n = (int)source.size();
    int XOR = 0, cnt = 0;
    for(int i = 0;i < n;++i){
        if(source[i]){
            XOR ^= (i + 1);
            cnt++;
        }
    }
    vector<int>res;
    if(n > 100){
        for(int i = 0;i < 8;++i){
            if(XOR & (1 << i)){
                res.push_back(1);
            }
            else{
                res.push_back(0);
            }
        }
    }
    else{
        for(int i = 0;i < 6;++i){
            if(XOR & (1 << i)){
                res.push_back(1);
            }
            else{
                res.push_back(0);
            }
        }
    }
    res.push_back(cnt & 1);
    return res;
}

vector<int> retrieve(vector<int> data) {
    int n = (int)source.size();
    vector<int>res;
    int XOR[2] = {}, par = 0, cnt = 0;
    if(n > 100){
        for(int i = 0;i < 255;++i){
            if(data[i]){
                XOR[0] ^= (i + 1);
                cnt++;
            }
            res.push_back(data[i]);
        }
        for(int i = 0;i < 8;++i){
            if(data[255 + i]){
                XOR[1] += (1 << i);
            }
        }
        par = data[263];
        if(XOR[0] != XOR[1] && cnt % 2 != par){
            int pos = XOR[0] ^ XOR[1];
            res[pos - 1] ^= 1;
        }
    }
    else{
        for(int i = 0;i < 63;++i){
            if(data[i]){
                XOR[0] ^= (i + 1);
                cnt++;
            }
            res.push_back(data[i]);
        }
        for(int i = 0;i < 6;++i){
            if(data[63 + i]){
                XOR[1] += (1 << i);
            }
        }
        par = data[69];
        if(XOR[0] != XOR[1] && cnt % 2 != par){
            int pos = XOR[0] ^ XOR[1];
            res[pos - 1] ^= 1;
        }
    }
    return res;
}

Compilation message

transfer.cpp: In function 'std::vector<int> retrieve(std::vector<int>)':
transfer.cpp:38:18: error: 'source' was not declared in this scope
   38 |     int n = (int)source.size();
      |                  ^~~~~~