Submission #247445

#TimeUsernameProblemLanguageResultExecution timeMemory
247445stoyan_malininData Transfer (IOI19_transfer)C++14
100 / 100
93 ms2776 KiB
#include "transfer.h" //#include "grader.cpp" #include<iostream> #include<vector> using namespace std; int BITCnt; vector<int> get_attachment(vector<int> source) { if(source.size()==63) BITCnt = 6; else BITCnt = 8; int val1 = 0, val2 = 0; for(int i = 0;i<source.size();i++) { if(source[i]==1) { val1 ^= 1; val2 ^= i + 1; } } vector <int> out; for(int bit = 0;bit<BITCnt;bit++) out.push_back(((val2>>bit)&1)); out.push_back(val1); return out; } vector<int> retrieve(vector<int> data) { if(data.size()==70) BITCnt = 6; else BITCnt = 8; vector <int> info; int val1 = 0, val2 = 0; int expectedVal1 = 0, expectedVal2 = 0; info = vector <int>(data.begin(), data.begin()+(data.size()-(BITCnt+1))); for(int i = 0;i<info.size();i++) { if(info[i]==1) { val1 ^= 1; val2 ^= i + 1; } } for(int i = (data.size()-(BITCnt+1));i<data.size()-1;i++) expectedVal2 += (data[i]<<(i-(data.size()-(BITCnt+1)))); expectedVal1 = data.back(); if(val1==expectedVal1 || val2==expectedVal2) return info; for(int i = 0;i<info.size();i++) { if((val2^(i+1))==expectedVal2) { info[i] ^= 1; return info; } } }

Compilation message (stderr)

transfer.cpp: In function 'std::vector<int> get_attachment(std::vector<int>)':
transfer.cpp:17:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i = 0;i<source.size();i++)
                   ~^~~~~~~~~~~~~~
transfer.cpp: In function 'std::vector<int> retrieve(std::vector<int>)':
transfer.cpp:43:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i = 0;i<info.size();i++)
                   ~^~~~~~~~~~~~
transfer.cpp:52:43: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i = (data.size()-(BITCnt+1));i<data.size()-1;i++) expectedVal2 += (data[i]<<(i-(data.size()-(BITCnt+1))));
                                          ~^~~~~~~~~~~~~~
transfer.cpp:56:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i = 0;i<info.size();i++)
                   ~^~~~~~~~~~~~
transfer.cpp:64:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...