제출 #1363979

#제출 시각아이디문제언어결과실행 시간메모리
1363979feyzaData Transfer (IOI19_transfer)C++20
0 / 100
3 ms1724 KiB
#include <bits/stdc++.h>
#include "transfer.h"

using namespace std;

std::vector<int> get_attachment(std::vector<int> source)
{
    int n=source.size();
    //cout<<"n "<<n<<endl;

    int lgn;
    vector<int>ans;

    if(n==63)
    {
        ans.resize(7,0);
        lgn=6;
    }
    else
    {
        ans.resize(9,0);
        lgn=8;
    }

    for(int i=0;i<n;i++)
    {
        ans[0]=(ans[0]^source[i]);

        for(int j=0;j<lgn;j++)
        {
            if((i+1) & (1<<j))
            {
                ans[1+j]^=source[i];
            }
        }
    }

    /*for(int i : ans)
        cout<<i;
    cout<<endl;*/

    return ans;
}

std::vector<int> retrieve(std::vector<int> data)
{
    /*cout<<"corrupt data"<<endl;
    for(int i : data)
        cout<<i;
    cout<<endl;*/

    int n,lgn;
    if(data.size()>=255)
    {
        n=255;
        lgn=8;
    }
    else
    {
        n=63;
        lgn=6;
    }

    vector<int>ans(n,0);

    int check=0;
    for(int i=0;i<n;i++)
    {
        ans[i]=data[i];
        check^=ans[i];
    }

    if(data[n]==check)
        return ans;

    vector<int>v(lgn);

    for(int i=0;i<n;i++)
    {
        for(int j=0;j<lgn;j++)
        {
            if((i+1) & (1<<j))
            {
                v[j]^=data[i];
            }
        }
    }

    /*cout<<"v ";
    for(int i : v)
        cout<<i<<' ';
    cout<<endl;*/

    int pos=0;
    for(int j=0;j<lgn;j++)
    {
        //cout<<j<<' '<<v[j]<<' '<<data[n+1+j]<<' '<<n+1+j<<endl;
        if(v[j]!=data[n+1+j])
            pos+=(1<<j);
    }

    //cout<<"pos "<<pos<<endl;

    ans[pos-1]=1-ans[pos-1];

    /*for(int i : ans)
        cout<<i;
    cout<<endl;*/

    return ans;
}

/**

1
2
100101011101001111010010101110100101011101001111010010101110111

**/

컴파일 시 표준 에러 (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)
      |     ^~~~~~~~~~~~~~
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…