Submission #941627

#TimeUsernameProblemLanguageResultExecution timeMemory
941627benjaminkleynData Transfer (IOI19_transfer)C++17
100 / 100
148 ms2544 KiB
#include <bits/stdc++.h> #include "transfer.h" using namespace std; vector<int> get_attachment(vector<int> source) { int K = (source.size() < 100 ? 7 : 9); vector<int> attachment; int x = 0; for (int i = 0; i < source.size(); i++) x ^= source[i]; source.push_back(x); attachment.push_back(x); for (int k = 0; k < K - 1; k++) { x = 0; for (int i = 0; i < source.size(); i++) if (i & (1 << k)) x ^= source[i]; attachment.push_back(x); } return attachment; } vector<int> retrieve(vector<int> data) { int K = (data.size() < 100 ? 7 : 9); vector<int> attachment(data.end() - (K - 1), data.end()); data = vector<int>(data.begin(), data.end() - (K - 1)); int x = 0; for (int i = 0; i < data.size(); i++) x ^= data[i]; if (x == 0) { data.pop_back(); return data; } int result = 0; for (int k = 0; k < K - 1; k++) { x = attachment[k]; for (int i = 0; i < data.size(); i++) if (i & (1 << k)) x ^= data[i]; if (x) result ^= (1 << k); } data[result] ^= 1; data.pop_back(); return data; }

Compilation message (stderr)

transfer.cpp: In function 'std::vector<int> get_attachment(std::vector<int>)':
transfer.cpp:10:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   10 |     for (int i = 0; i < source.size(); i++)
      |                     ~~^~~~~~~~~~~~~~~
transfer.cpp:17:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   17 |         for (int i = 0; i < source.size(); i++)
      |                         ~~^~~~~~~~~~~~~~~
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 = 0; i < data.size(); i++)
      |                     ~~^~~~~~~~~~~~~
transfer.cpp:42:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   42 |         for (int i = 0; i < data.size(); i++)
      |                         ~~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...