Submission #573166

#TimeUsernameProblemLanguageResultExecution timeMemory
573166JomnoiData Transfer (IOI19_transfer)C++17
100 / 100
79 ms2500 KiB
#include <bits/stdc++.h> #include "transfer.h" using namespace std; vector <int> get_attachment(vector <int> source) { int X = 0, cnt1 = 0, sz = log2(source.size() + 1); for(int i = 0; i < source.size(); i++) { if(source[i] == 1) { X ^= (i + 1); } } vector <int> K; while(X > 0 or K.size() < sz) { K.push_back(X % 2); cnt1 += X % 2; X /= 2; } K.push_back(cnt1 % 2); return K; } vector <int> retrieve(vector <int> data) { int cnt1 = data.back(), sz = log2(data.size()), X = 0; data.pop_back(); while(sz--) { X *= 2; X += data.back(); cnt1 += data.back(); data.pop_back(); } if(cnt1 % 2 == 1) { return data; } for(int i = 0; i < data.size(); i++) { if(data[i] == 1) { X ^= (i + 1); } } if(X != 0) { data[X - 1] ^= 1; } return data; }

Compilation message (stderr)

transfer.cpp: In function 'std::vector<int> get_attachment(std::vector<int>)':
transfer.cpp:7:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    7 |  for(int i = 0; i < source.size(); i++) {
      |                 ~~^~~~~~~~~~~~~~~
transfer.cpp:14:26: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   14 |  while(X > 0 or K.size() < sz) {
      |                 ~~~~~~~~~^~~~
transfer.cpp: In function 'std::vector<int> retrieve(std::vector<int>)':
transfer.cpp:39:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   39 |  for(int i = 0; i < data.size(); i++) {
      |                 ~~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...