Submission #1310757

#TimeUsernameProblemLanguageResultExecution timeMemory
1310757lizi14Data Transfer (IOI19_transfer)C++20
0 / 100
7 ms3252 KiB
#include "transfer.h"
#include <bits/stdc++.h>
using namespace std;
int N;
vector<int> get_attachment(vector<int>source){
    N=source.size();
    vector<int>k={0,0,0,0,0,0,0,0};
    int bati=0;
    for(int i=1; i<=N; i++){
        if(source[i-1]==1){
            bati^=i;
        }
    }
    vector<int>h;
    for(int i=0; i<=log2(bati); i++){
        if(bati&(1<<i))h.push_back(1);
        else h.push_back(0);
    }
    int ixvi=0;
    for(int i=0; i<h.size(); i++){
        k[i]=h[i];
        if(h[i]==1)ixvi++;
    }
    vector<int>data;
    data=source;
    for(int i=0; i<k.size(); i++){
        data.push_back(k[i]);
    }
    //data=data+(k.begin(), k.end());
    if(ixvi%2==0)data.push_back(0);
    else data.push_back(1);
    return data;
	//return { 0, 1, 0 };
	
}

vector<int>retrieve(vector<int>data){
    int bati=0;
    for(int i=1; i<=N; i++){
        if(data[i-1]==1){
            bati^=i;
        }
    }
    int ixvi=0;
    int drnachvi=0;
    for(int i=N; i<N+8; i++){
        if(data[i]==1){
            drnachvi++;
            ixvi+=(1<<(i-N));
        }
    }
    if(ixvi==bati){
        vector<int>v;
        for(int i=0; i<N; i++){
            v.push_back(data[i]);
        }
        return v;
    }
    int m=data.size();
    if(drnachvi%2==data[m-1]){
        int idex=ixvi^bati;
        vector<int>v;
        for(int i=0; i<N; i++){
            if(i==idex-1){
                v.push_back(1-data[i]);
                continue;
            }
            else{
                v.push_back(data[i]);
            }
        }
        return v;
    }
    else{
        vector<int>v;
        for(int i=0; i<N; i++){
            v.push_back(data[i]);
        }
        return v;
    }
	//return vector<int>(data.begin(), data.end()-3);
}

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...