Submission #973261

# Submission time Handle Problem Language Result Execution time Memory
973261 2024-05-01T16:52:41 Z vjudge1 Data Transfer (IOI19_transfer) C++17
100 / 100
42 ms 2772 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 1 ms 800 KB Output is correct
2 Correct 1 ms 800 KB Output is correct
3 Correct 2 ms 800 KB Output is correct
4 Correct 1 ms 804 KB Output is correct
5 Correct 1 ms 784 KB Output is correct
6 Correct 1 ms 792 KB Output is correct
7 Correct 1 ms 792 KB Output is correct
8 Correct 3 ms 884 KB Output is correct
9 Correct 1 ms 792 KB Output is correct
10 Correct 1 ms 888 KB Output is correct
11 Correct 1 ms 800 KB Output is correct
12 Correct 1 ms 800 KB Output is correct
13 Correct 1 ms 800 KB Output is correct
14 Correct 1 ms 800 KB Output is correct
15 Correct 2 ms 800 KB Output is correct
16 Correct 2 ms 792 KB Output is correct
17 Correct 2 ms 800 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 30 ms 2504 KB Output is correct
2 Correct 29 ms 2516 KB Output is correct
3 Correct 30 ms 2556 KB Output is correct
4 Correct 34 ms 2520 KB Output is correct
5 Correct 35 ms 2512 KB Output is correct
6 Correct 41 ms 2520 KB Output is correct
7 Correct 37 ms 2508 KB Output is correct
8 Correct 32 ms 2504 KB Output is correct
9 Correct 31 ms 2512 KB Output is correct
10 Correct 34 ms 2504 KB Output is correct
11 Correct 31 ms 2512 KB Output is correct
12 Correct 36 ms 2516 KB Output is correct
13 Correct 29 ms 2508 KB Output is correct
14 Correct 36 ms 2508 KB Output is correct
15 Correct 34 ms 2516 KB Output is correct
16 Correct 35 ms 2504 KB Output is correct
17 Correct 42 ms 2520 KB Output is correct
18 Correct 38 ms 2772 KB Output is correct
19 Correct 32 ms 2504 KB Output is correct