Submission #973172

# Submission time Handle Problem Language Result Execution time Memory
973172 2024-05-01T15:13:56 Z sleepntsheep Data Transfer (IOI19_transfer) C++14
0 / 100
4 ms 2504 KB
#include "transfer.h"

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

std::vector<int> retrieve(std::vector<int> data) {
    int xorsum = 0;
    int n = (int)data.size() - 9;
    for (int i = 0; i < n; ++i)
        if (data[i]) xorsum ^= i;

    int xordat = 0;
    for (int i = n; i < n + 8; ++i)
        if (data[i]) xordat ^= (1<<(i-n));
    while (data.size() > n) data.pop_back();
    if (__builtin_parity(xordat) != data.back())
        return data;

    int i = xorsum ^ xordat;
    data[i] ^= 1;
    return data;
}

Compilation message

transfer.cpp: In function 'std::vector<int> retrieve(std::vector<int>)':
transfer.cpp:22:24: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   22 |     while (data.size() > n) data.pop_back();
      |            ~~~~~~~~~~~~^~~
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 800 KB WA in grader: wrong source retrieval
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 2504 KB WA in grader: wrong source retrieval
2 Halted 0 ms 0 KB -