Submission #560607

# Submission time Handle Problem Language Result Execution time Memory
560607 2022-05-11T17:42:21 Z MilosMilutinovic Data Transfer (IOI19_transfer) C++14
0 / 100
9 ms 2492 KB
#include "transfer.h"
#include <bits/stdc++.h>

using namespace std;

vector<int> get_attachment(vector<int> source) {
  int n = source.size();
  vector<int> ret(9);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 8; j++) {
      if ((i + 1) >> j & 1) {
        ret[j] ^= source[i];
      }
    }
    ret[8] ^= source[i];
  }
  return ret;
}

vector<int> retrieve(vector<int> data) {
  int n = data.size();
  int f = 0;
  for (int i = 0; i < n - 9; i++) {
    f ^= data[i];
  }
  if (f != data.back()) {
    return vector<int>(data.begin(), data.begin() + n - 9);
  }
  vector<int> r(8);         
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 8; j++) {
      if ((i + 1) >> j & 1) {
        r[j] ^= data[i];
      }
    }
  }
  int pos = 0;
  for (int i = 0; i < 8; i++) {
    if (r[i] != data[n - 9 + i]) {
      pos += (1 << i);
    }
  }
  pos--;
  data[pos] ^= 1;
  return vector<int>(data.begin(), data.begin() + n - 9);
}
# 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 Incorrect 9 ms 2492 KB WA in grader: wrong source retrieval
2 Halted 0 ms 0 KB -