Submission #1310834

#TimeUsernameProblemLanguageResultExecution timeMemory
1310834nikoloz-chData Transfer (IOI19_transfer)C++20
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #include "transfer.h" using namespace std; vector<int> get_attachment(vector<int> source){ int p = 0, k = 0, kp = 0; const int n = source.size(); kp = (n == 63 ? 6 : 8); for(int i = 0; i < n; i++) if(source[i]) p ^= source[i]; auto t = bitset<kp>(p); for(int i = 0; i < t.size(); i++) source.push_back(t[i]), k += (t[i] ? 1 : 0); source.push_back(k % 2); } vector<int> retrieve(vector<int> data){ int p = 0, k = 0, kp = 0; const int n = data.size(); for(int i = 0; i < n-(n >= 255 ? 9 : 7); i++) if(data[i]) p ^= data[i]; for(int i = n; i < n+(n >= 255 ? 8 : 6); i++){ if(data[i]) k += (1<<(i-n)); kp += (data[i] ? 1 : 0); } vector<int> ans; if(data.back() != kp % 2){ for(int i = 0; i < n-(n >= 255 ? 9 : 7); i++) ans.push_back(data[i]); return ans; } for(int i = 0; i < n-(n >= 255 ? 9 : 7); i++){ if(i == (p^k)) ans.push_back((data[i] ? 0 : 1)); else ans.push_back(data[i]); } return ans; }

Compilation message (stderr)

transfer.cpp: In function 'std::vector<int> get_attachment(std::vector<int>)':
transfer.cpp:8:23: error: the value of 'kp' is not usable in a constant expression
    8 |     auto t = bitset<kp>(p);
      |                       ^
transfer.cpp:6:23: note: 'int kp' is not const
    6 |     int p = 0, k = 0, kp = 0; const int n = source.size(); kp = (n == 63 ? 6 : 8);
      |                       ^~
transfer.cpp:8:23: note: in template argument for type 'long unsigned int'
    8 |     auto t = bitset<kp>(p);
      |                       ^
transfer.cpp:11:1: warning: no return statement in function returning non-void [-Wreturn-type]
   11 | }
      | ^
grader.cpp: In instantiation of 'void shuffle(std::vector<T>&) [with T = Scenario]':
grader.cpp:200:10:   required from here
grader.cpp:28:23: warning: 'void std::random_shuffle(_RAIter, _RAIter) [with _RAIter = __gnu_cxx::__normal_iterator<Scenario*, vector<Scenario> >]' is deprecated: use 'std::shuffle' instead [-Wdeprecated-declarations]
   28 |         random_shuffle(v.begin(), v.end());
      |         ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/13/algorithm:61,
                 from grader.cpp:8:
/usr/include/c++/13/bits/stl_algo.h:4581:5: note: declared here
 4581 |     random_shuffle(_RandomAccessIterator __first, _RandomAccessIterator __last)
      |     ^~~~~~~~~~~~~~