Submission #973176

# Submission time Handle Problem Language Result Execution time Memory
973176 2024-05-01T15:20:17 Z sleepntsheep Data Transfer (IOI19_transfer) C++17
100 / 100
46 ms 2764 KB
#include "transfer.h"

std::vector<int> get_attachment(std::vector<int> source) {
    int A;
    if (source.size() == 63) A = 6;
    else A = 8;

    int xorsum = 0;
    std::vector<int> v;
    for (int i = 0; i < (int)source.size(); ++i)
        if (source[i]) xorsum ^= i + 1;
    for (int i = 0; i < A; ++i) v.push_back((xorsum>>i)&1);
    v.push_back(__builtin_parity(xorsum));
    return v;
}

std::vector<int> retrieve(std::vector<int> data) {
    int A;
    if (data.size() < 100) A = 6;
    else A = 8;

    int xorsum = 0;
    int n = (int)data.size() - A - 1;
    for (int i = 0; i < n; ++i)
        if (data[i]) xorsum ^= i + 1;

    int xordat = 0, dat_par = data.back();
    for (int i = n; i < n + A; ++i)
        xordat ^= (data[i]<<(i-n));

    while ((int)data.size() > n) data.pop_back();
    if (__builtin_parity(xordat) != dat_par)
        return data;

    int i = xorsum ^ xordat;
    if(i)
        data[i-1] ^= 1;
    return data;
}

# Verdict Execution time Memory Grader output
1 Correct 2 ms 780 KB Output is correct
2 Correct 2 ms 788 KB Output is correct
3 Correct 1 ms 788 KB Output is correct
4 Correct 1 ms 1048 KB Output is correct
5 Correct 1 ms 788 KB Output is correct
6 Correct 2 ms 796 KB Output is correct
7 Correct 3 ms 796 KB Output is correct
8 Correct 1 ms 788 KB Output is correct
9 Correct 2 ms 788 KB Output is correct
10 Correct 2 ms 780 KB Output is correct
11 Correct 2 ms 1096 KB Output is correct
12 Correct 2 ms 788 KB Output is correct
13 Correct 1 ms 788 KB Output is correct
14 Correct 1 ms 796 KB Output is correct
15 Correct 2 ms 796 KB Output is correct
16 Correct 1 ms 796 KB Output is correct
17 Correct 2 ms 784 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 37 ms 2512 KB Output is correct
2 Correct 35 ms 2512 KB Output is correct
3 Correct 34 ms 2504 KB Output is correct
4 Correct 34 ms 2512 KB Output is correct
5 Correct 36 ms 2516 KB Output is correct
6 Correct 41 ms 2508 KB Output is correct
7 Correct 37 ms 2508 KB Output is correct
8 Correct 32 ms 2504 KB Output is correct
9 Correct 32 ms 2512 KB Output is correct
10 Correct 38 ms 2512 KB Output is correct
11 Correct 31 ms 2512 KB Output is correct
12 Correct 32 ms 2512 KB Output is correct
13 Correct 30 ms 2504 KB Output is correct
14 Correct 36 ms 2512 KB Output is correct
15 Correct 46 ms 2512 KB Output is correct
16 Correct 39 ms 2512 KB Output is correct
17 Correct 35 ms 2512 KB Output is correct
18 Correct 46 ms 2508 KB Output is correct
19 Correct 33 ms 2764 KB Output is correct