답안 #156504

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
156504 2019-10-06T08:56:59 Z WLZ Data Transfer (IOI19_transfer) C++17
100 / 100
392 ms 2844 KB
#include "transfer.h"
#include <bits/stdc++.h>
using namespace std;

vector<int> get_attachment(vector<int> source) {
  int n = (int) source.size();
  vector<int> ans;
  for (int i = 0; (1 << i) < n; i++) {
    ans.push_back(0);
    for (int j = 1; j <= n; j++) {
      if (j & (1 << i)) {
        ans.back() = (ans.back() + source[j - 1]) % 2;
      }
    }
  }
  ans.push_back(accumulate(ans.begin(), ans.end(), 0) % 2);
  return move(ans);
}

vector<int> retrieve(vector<int> data) {
  int n = ((int) data.size() == 70 ? 63 : 255);
  int x = 0;
  for (int i = n; i < (int) data.size() - 1; i++) {
    x = (x + data[i]) % 2;
  }
  if (x == data.back()) {
    vector<int> tmp;
    for (int i = 0; (1 << i) < n; i++) {
      tmp.push_back(0);
      for (int j = 1; j <= n; j++) {
        if (j & (1 << i)) {
          tmp.back() = (tmp.back() + data[j - 1]) % 2;
        }
      }
    }
    int k = 0;
    for (int i = 0; (1 << i) < n; i++) {
      if (tmp[i] != data[n + i]) {
        k += (1 << i);
      }
    }
    if (k > 0) {
      data[k - 1] = !data[k - 1];
    }
  }
  return vector<int>(data.begin(), data.begin() + n);
}
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 916 KB Output is correct
2 Correct 10 ms 1020 KB Output is correct
3 Correct 10 ms 1052 KB Output is correct
4 Correct 10 ms 1028 KB Output is correct
5 Correct 10 ms 1100 KB Output is correct
6 Correct 10 ms 980 KB Output is correct
7 Correct 10 ms 892 KB Output is correct
8 Correct 10 ms 928 KB Output is correct
9 Correct 10 ms 968 KB Output is correct
10 Correct 10 ms 1028 KB Output is correct
11 Correct 10 ms 892 KB Output is correct
12 Correct 10 ms 904 KB Output is correct
13 Correct 10 ms 892 KB Output is correct
14 Correct 10 ms 1020 KB Output is correct
15 Correct 10 ms 916 KB Output is correct
16 Correct 10 ms 900 KB Output is correct
17 Correct 10 ms 892 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 388 ms 2844 KB Output is correct
2 Correct 388 ms 2484 KB Output is correct
3 Correct 390 ms 2476 KB Output is correct
4 Correct 391 ms 2480 KB Output is correct
5 Correct 390 ms 2484 KB Output is correct
6 Correct 387 ms 2480 KB Output is correct
7 Correct 390 ms 2480 KB Output is correct
8 Correct 389 ms 2624 KB Output is correct
9 Correct 387 ms 2656 KB Output is correct
10 Correct 387 ms 2604 KB Output is correct
11 Correct 386 ms 2480 KB Output is correct
12 Correct 386 ms 2480 KB Output is correct
13 Correct 386 ms 2628 KB Output is correct
14 Correct 392 ms 2624 KB Output is correct
15 Correct 387 ms 2616 KB Output is correct
16 Correct 387 ms 2616 KB Output is correct
17 Correct 387 ms 2628 KB Output is correct
18 Correct 390 ms 2616 KB Output is correct
19 Correct 389 ms 2616 KB Output is correct