Submission #550090

# Submission time Handle Problem Language Result Execution time Memory
550090 2022-04-17T08:46:12 Z PunnyBunny Data Transfer (IOI19_transfer) C++17
100 / 100
44 ms 2560 KB
#include "transfer.h"

#include <bits/stdc++.h>
using namespace std;
std::vector<int> get_attachment(std::vector<int> source) {
    int n = source.size(), sum = 0;
    for (int i = 0; i < n; ++i) {
        sum ^= (i + 1) * source[i];
    }

    int k = n == 63 ? 7 : 9;
    vector<int> res(k);
    for (int i = 0; i < 1 << k; ++i) {
        int x = 0;
        for (int j = 0; j < k - 1; ++j) x ^= (i >> j & 1) * (n + 1 + (1 << j));
        x ^= (i >> (k - 1) & 1) * (n + 1);
        if (x == sum) {
            for (int j = 0; j < k; ++j) res[j] = i >> j & 1;
            break;
        }
    }
    return res;
}

std::vector<int> retrieve(std::vector<int> data) {
    int n = data.size() > 100 ? 255 : 63, sum = 0;
    for (int i = 0; i < n; ++i) {
        sum ^= (i + 1) * data[i];
    }

    for (int i = n; i < data.size(); ++i) {
        if (i == data.size() - 1) {
            sum ^= data[i] * (n + 1);
        } else {
            sum ^= data[i] * (n + 1 + (1 << (i - n)));
        }
    }

    if (sum > 0) data[sum - 1] ^= 1;
    return {data.begin(), data.begin() + n};
}

Compilation message

transfer.cpp: In function 'std::vector<int> retrieve(std::vector<int>)':
transfer.cpp:31:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   31 |     for (int i = n; i < data.size(); ++i) {
      |                     ~~^~~~~~~~~~~~~
transfer.cpp:32:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   32 |         if (i == data.size() - 1) {
      |             ~~^~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 648 KB Output is correct
2 Correct 3 ms 644 KB Output is correct
3 Correct 2 ms 648 KB Output is correct
4 Correct 3 ms 652 KB Output is correct
5 Correct 3 ms 732 KB Output is correct
6 Correct 2 ms 636 KB Output is correct
7 Correct 2 ms 644 KB Output is correct
8 Correct 2 ms 736 KB Output is correct
9 Correct 3 ms 644 KB Output is correct
10 Correct 2 ms 652 KB Output is correct
11 Correct 2 ms 648 KB Output is correct
12 Correct 3 ms 644 KB Output is correct
13 Correct 3 ms 652 KB Output is correct
14 Correct 3 ms 644 KB Output is correct
15 Correct 3 ms 652 KB Output is correct
16 Correct 3 ms 656 KB Output is correct
17 Correct 3 ms 656 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 43 ms 2500 KB Output is correct
2 Correct 42 ms 2496 KB Output is correct
3 Correct 41 ms 2492 KB Output is correct
4 Correct 42 ms 2492 KB Output is correct
5 Correct 41 ms 2500 KB Output is correct
6 Correct 44 ms 2472 KB Output is correct
7 Correct 42 ms 2500 KB Output is correct
8 Correct 40 ms 2500 KB Output is correct
9 Correct 41 ms 2444 KB Output is correct
10 Correct 40 ms 2492 KB Output is correct
11 Correct 40 ms 2496 KB Output is correct
12 Correct 42 ms 2500 KB Output is correct
13 Correct 40 ms 2452 KB Output is correct
14 Correct 42 ms 2504 KB Output is correct
15 Correct 43 ms 2492 KB Output is correct
16 Correct 42 ms 2488 KB Output is correct
17 Correct 44 ms 2560 KB Output is correct
18 Correct 42 ms 2452 KB Output is correct
19 Correct 40 ms 2492 KB Output is correct