Submission #1331812

#TimeUsernameProblemLanguageResultExecution timeMemory
1331812khanhphucscratchData Transfer (IOI19_transfer)C++20
100 / 100
151 ms1724 KiB
#include "transfer.h"
#include<bits/stdc++.h>
using namespace std;
inline bool getbit(int num, int bit)
{
    return (num >> bit)&1;
}
vector<int> get_attachment(vector<int> source) {
	int n = source.size(), d = __lg(n);
	vector<int> add(d+1);
    for(int i = 0; i < n; i++){
        for(int j = 0; j <= d; j++) if(getbit(i, j) == 0) add[j] ^= source[i];
    }
    int sum = 0;
    for(int i : add) sum ^= i;
    add.push_back(sum);
    return add;
}

vector<int> retrieve(vector<int> data) {
    int n = 1;
    while(n <= data.size()) n <<= 1;
    n >>= 1; n--; int d = __lg(n);
    int sum = 0;
    for(int i = n; i < data.size(); i++) sum ^= data[i];
    if(sum == 1){
        vector<int> ans;
        for(int i = 0; i < n; i++) ans.push_back(data[i]);
        return ans;
    }
    data.pop_back();
    int place = 0;
    for(int j = 0; j <= d; j++){
        int sum = data[n+j];
        for(int i = 0; i < n; i++) if(getbit(i, j) == 0) sum ^= data[i];
        if(sum == 0) place += (1 << j);
    }
    vector<int> ans;
    for(int i = 0; i < n; i++) ans.push_back(data[i]);
    if(place < n) ans[place] ^= 1;
    return ans;
}

Compilation message (stderr)

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)
      |     ^~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...