Submission #679304

#TimeUsernameProblemLanguageResultExecution timeMemory
679304ar88loData Transfer (IOI19_transfer)C++14
100 / 100
132 ms2548 KiB
#include "transfer.h" std::vector<int> get_attachment(std::vector<int> source) { int x,lg,cnt; std::vector<int> ret; cnt = x = 0; lg = (source.size() == 63)?6:8; for(int i = 1; i <= source.size(); i++){ if(source[i-1]){ x ^= i; } } while(x > 0){ cnt += x%2; ret.push_back(x%2); x/=2; } while(ret.size() < lg){ ret.push_back(0); } ret.push_back(cnt%2); return ret; } std::vector<int> retrieve(std::vector<int> data) { int a,x,k,lg,cnt; std::vector<int> ret; k = 1; lg = (data.size() == 70)?6:8; cnt = x = a = 0; for(int i = data.size() - lg - 1; i < data.size() - 1; i++){ if(data[i]) cnt++; a += data[i]*k; k*=2; } for(int i = 0; i < data.size() - lg - 1; i++){ ret.push_back(data[i]); } if(data[data.size()-1] == cnt%2){ for(int i = 1; i <= data.size() - lg - 1; i++){ if(data[i-1]){ x ^= i; } } x = x^a; if(x!=0) ret[x-1] = !ret[x-1]; } return ret; }

Compilation message (stderr)

transfer.cpp: In function 'std::vector<int> get_attachment(std::vector<int>)':
transfer.cpp:8:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    8 |     for(int i = 1; i <= source.size(); i++){
      |                    ~~^~~~~~~~~~~~~~~~
transfer.cpp:19:22: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   19 |     while(ret.size() < lg){
      |           ~~~~~~~~~~~^~~~
transfer.cpp: In function 'std::vector<int> retrieve(std::vector<int>)':
transfer.cpp:32:41: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   32 |     for(int i = data.size() - lg - 1; i < data.size() - 1; i++){
      |                                       ~~^~~~~~~~~~~~~~~~~
transfer.cpp:38:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   38 |     for(int i = 0; i < data.size() - lg - 1; i++){
      |                    ~~^~~~~~~~~~~~~~~~~~~~~~
transfer.cpp:44:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   44 |         for(int i = 1; i <= data.size() - lg - 1; i++){
      |                        ~~^~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...