답안 #367618

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
367618 2021-02-17T18:59:17 Z PurpleCrayon Data Transfer (IOI19_transfer) C++17
0 / 100
7 ms 2468 KB
#include "transfer.h"
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
#define sz(v) int(v.size())

vector<int> get_attachment(vector<int> a) {
    int n = sz(a), B = 31-__builtin_clz(n);

    assert(n&(1<<B)), assert((1<<(B+1))>n);

    vector<int> ans{0};
    for (auto v : a) ans.back() ^= v;
    ans.push_back(ans.back());

    for (int i = 0; i <= B; i++){
        ans.push_back(0);
        for (int j = 0; j < n; j++) if ((j>>i)&1) ans.back() ^= a[j];
    }
    return ans;
}
vector<int> retrieve(vector<int> a) {
    int n=-1;
    if (sz(a) >= 255) n = 255;
    else n = 63;

    vector<int> ans(a.begin(), a.begin()+n);
    if (a[n] != a[n+1]){
        return ans;
    }
    {
        int c=0;
        for (int i = 0; i < n; i++) c ^= a[i];

        if (c == a[n]) return ans;
    }

    int idx=0;

    int B = 31-__builtin_clz(n);
    assert(n&(1<<B)), assert((1<<(B+1))>n);
    for (int i = 0; i <= B; i++){
        int rl=0;
        for (int j = 0; j < n; j++) if ((j>>i)&1) rl ^= a[j];

        if (rl != a[n+2+rl]){
            idx ^= 1<<i;
        }
    }
    ans[idx] ^= 1;
    return ans;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 4 ms 1100 KB WA in grader: wrong source retrieval
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 7 ms 2468 KB WA in grader: wrong source retrieval
2 Halted 0 ms 0 KB -