Submission #550090

#TimeUsernameProblemLanguageResultExecution timeMemory
550090PunnyBunnyData Transfer (IOI19_transfer)C++17
100 / 100
44 ms2560 KiB
#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 (stderr)

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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...