Submission #864602

#TimeUsernameProblemLanguageResultExecution timeMemory
864602ThylOneData Transfer (IOI19_transfer)C++14
60 / 100
4 ms2508 KiB
#include "transfer.h" #include<bits/stdc++.h> using namespace std; std::vector<int> get_attachment(std::vector<int> source) { int xorIndex=0; int xor0; for(int i=1;i<=source.size();i++){ if(source[i-1]){ xorIndex^=i; } } vector<int> bits(7); int sum=0; for(int i=0;i<6;i++){ bits[i]=(xorIndex>>i)&1; sum+=bits[i]; } bits[6]=sum&1; return bits; } std::vector<int> retrieve(std::vector<int> data) { int len = data.size()-7; int xorIndex=0; for(int i=1;i<=len;i++){ if(data[i-1]){ xorIndex^=i; } } int restitution=0; int sum=0; for(int i=0;i<6;i++){ if(data[i+len]){ restitution+=(1<<i); } sum+=data[i+len]; } int fake = xorIndex^restitution; vector<int> real=data; for(int i=0;i<7;i++)real.pop_back(); if(fake>0 && !((sum&1)!=data[data.size()-1])) real[fake-1] = !real[fake-1]; return real; }

Compilation message (stderr)

transfer.cpp: In function 'std::vector<int> get_attachment(std::vector<int>)':
transfer.cpp:10:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   10 |  for(int i=1;i<=source.size();i++){
      |              ~^~~~~~~~~~~~~~~
transfer.cpp:9:6: warning: unused variable 'xor0' [-Wunused-variable]
    9 |  int xor0;
      |      ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...