Submission #1175767

#TimeUsernameProblemLanguageResultExecution timeMemory
1175767mannshah1211Data Transfer (IOI19_transfer)C++20
100 / 100
55 ms1820 KiB
#include "transfer.h"
#include <bits/stdc++.h>

using namespace std;

vector<int> get_attachment(vector<int> source) {
  if (source.size() == 63) {
    int xo = 0, cnt = 0;
    for (int i = 0; i < source.size(); i++) {
      if (source[i] == 0) {
        xo ^= (i + 1);
        cnt++;
      } 
    }
    vector<int> attachment;
    for (int i = 5; i >= 0; i--) {
      if (xo & (1 << i)) {
        attachment.push_back(1);
      } else {
        attachment.push_back(0);
      }
    }
    attachment.push_back(cnt % 2);
    return attachment;
  }
  int xo = 0, cnt = 0;
  for (int i = 0; i < source.size(); i++) {
    if (source[i] == 0) {
      xo ^= (i + 1);
      cnt++;
    } 
  }
  vector<int> attachment;
  for (int i = 7; i >= 0; i--) {
    if (xo & (1 << i)) {
      attachment.push_back(1);
    } else {
      attachment.push_back(0);
    }
  }
  attachment.push_back(cnt % 2);
  return attachment;
}

vector<int> retrieve(vector<int> data) {
  if (data.size() == 70) {
    int xo = 0, cnt = 0;
    for (int i = 0; i < data.size() - 7; i++) {
      if (data[i] == 0) {
        xo ^= (i + 1);
        cnt++;
      }
    }
    vector<int> ans;
    for (int i = 0; i < data.size() - 7; i++) {
      ans.push_back(data[i]);
    }
    int reported_parity = data[data.size() - 1], reported_xo = 0;
    for (int i = data.size() - 7; i < data.size() - 1; i++) {
      reported_xo = (2 * reported_xo) + data[i];
    }
    if (xo == reported_xo || cnt % 2 == reported_parity) {
      return ans;
    } 
    ans[(xo ^ reported_xo) - 1] = 1 - ans[(xo ^ reported_xo) - 1];
    return ans;
  }
  int xo = 0, cnt = 0;
  for (int i = 0; i < data.size() - 9; i++) {
    if (data[i] == 0) {
      xo ^= (i + 1);
      cnt++;
    }
  }
  vector<int> ans;
  for (int i = 0; i < data.size() - 9; i++) {
    ans.push_back(data[i]);
  }
  int reported_parity = data[data.size() - 1], reported_xo = 0;
  for (int i = data.size() - 9; i < data.size() - 1; i++) {
    reported_xo = (2 * reported_xo) + data[i];
  }
  if (xo == reported_xo || cnt % 2 == reported_parity) {
    return ans;
  } 
  ans[(xo ^ reported_xo) - 1] = 1 - ans[(xo ^ reported_xo) - 1];
  return ans;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...