Submission #1006152

# Submission time Handle Problem Language Result Execution time Memory
1006152 2024-06-23T13:36:09 Z basa Data Transfer (IOI19_transfer) C++14
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
#include "transfer.h"

using namespace std;

const int maxn = 63;

vector<int>get_attachment(vector<int>a)
{
  int eo = 0;
  int one = 0;
  int n = N;

  vector<int>ret;
  for(int i = 0; i < n; i++){
    eo ^= a[i];
    if(a[i] == 1) one ^= i + 1;
    ret.push_back(a[i]);
  }

  for(int i = 7; i >= 0; i--){
    int bit = 1 << i;
    if(one >= bit){
      one -= bit;
      ret.push_back(1);
    }
    else ret.push_back(0);
  }
  ret.push_back(eo);

  return ret;
}

vector<int> retrieve(vector<int> data)
{
  int eo = 0;
  int back = 0;
  int datasize = data.size();

  for(int i = N; i < datasize - 1; i++){
    eo ^= data[i];
    if(data[i]) back += 1 << (7 - (i - N));
  }

  vector<int>ret;
  for(int i = 0; i < N; i++) ret.push_back(data[i]);

  if(eo != data.back()) return ret;

  int p = 0;
  for(int i = 0; i < N; i++){
    if(data[i]) p ^= i + 1;
  }

  if((p ^ back) > 0) ret[(p ^ back) - 1] = !ret[(p ^ back) - 1];
  return ret;
}

Compilation message

transfer.cpp: In function 'std::vector<int> get_attachment(std::vector<int>)':
transfer.cpp:12:11: error: 'N' was not declared in this scope
   12 |   int n = N;
      |           ^
transfer.cpp: In function 'std::vector<int> retrieve(std::vector<int>)':
transfer.cpp:40:15: error: 'N' was not declared in this scope
   40 |   for(int i = N; i < datasize - 1; i++){
      |               ^
transfer.cpp:46:22: error: 'N' was not declared in this scope
   46 |   for(int i = 0; i < N; i++) ret.push_back(data[i]);
      |                      ^
transfer.cpp:51:22: error: 'N' was not declared in this scope
   51 |   for(int i = 0; i < N; i++){
      |                      ^