Submission #829691

#TimeUsernameProblemLanguageResultExecution timeMemory
829691baneData Transfer (IOI19_transfer)C++17
100 / 100
106 ms2496 KiB
#include "transfer.h" #include<vector> using namespace std; std::vector<int> get_attachment(std::vector<int> source) { int tot = 0; if (source.size() <= 63)tot = 6; else tot = 8; vector<int>adding(tot + 1, 0); int odd = 0; for (int i = 0; i < source.size(); i++){ odd += source[i]; } adding.back() = odd & 1; int a = 0; for (int i = 0; i < source.size(); i++){ if (source[i]){ a ^= (i + 1); } } for (int j = 0; j < tot; j++){ if (a & (1 << j))adding[j] = 1; } return adding; } std::vector<int> retrieve(std::vector<int> data) { if (data.size() > 100){ int odd = 0; for (int i = 0 ; i < 255; i++){ odd += data[i]; } odd = odd & 1; int xr = 0, xr2 = 0; for (int i = 0; i < 8; i++){ if (data[255 + i])xr2 ^= (1 << i); } for (int i = 0; i < 255; i++){ if (data[i])xr ^= (i + 1); } int ok = (xr == xr2); if (!ok){ if (odd != data.back()){ //first half is fucked for (int i = 0; i < 255; i++){ if ((xr ^ (i + 1)) == xr2){ data[i] ^= 1; //return data; } } }else{ //second half is fucked for (int i = 0; i < 8; i++){ if (((1 << i) ^xr2) == xr){ data[255 + i] ^= 1; //return data; } } } }else{ data.back() ^= 1; } vector<int>ans; for (int i = 0; i < 255; i++)ans.push_back(data[i]); return ans; }else{ int odd = 0; for (int i = 0 ; i < 63; i++){ odd += data[i]; } odd = odd & 1; int xr = 0, xr2 = 0; for (int i = 0; i < 6; i++){ if (data[63 + i])xr2 ^= (1 << i); } for (int i = 0; i < 63; i++){ if (data[i])xr ^= (i + 1); } int ok = (xr == xr2); if (!ok){ if (odd != data.back()){ //first half is fucked for (int i = 0; i < 63; i++){ if ((xr ^ (i + 1)) == xr2){ data[i] ^= 1; //return data; } } }else{ //second half is fucked for (int i = 0; i < 6; i++){ if (((1 << i) ^xr2) == xr){ data[63 + i] ^= 1; //return data; } } } }else{ data.back() ^= 1; //return data; } vector<int>ans; for (int i = 0; i < 63; i++)ans.push_back(data[i]); return ans; } return data; }

Compilation message (stderr)

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