답안 #358584

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
358584 2021-01-25T22:35:33 Z Ahmad_Hasan Data Transfer (IOI19_transfer) C++17
100 / 100
230 ms 2644 KB
#include "transfer.h"
#include <bits/stdc++.h>
using namespace std;


vector<int> get_attachment(vector<int>src){
    if(src.size()<=3){
        int n=src.size();
        for(int i=0;i<n;i++)src.push_back(src[i]);
        return src;
    }

    int n =src.size();
    int p=7;
    if(n>63)
        p=9;

    vector<int>ret(p);

    int sz=ret.size();
    for(int i=0;i<sz;i++){
        for(int j=0;j<n;j+=2*(1<<i)){
            for(int k=0;k<(1<<i);k++)
                if(j+k<n)
                    ret[i]^=src[j+k];
        }
    }

    return ret;
}

vector<int> retrieve(vector<int>data){
    vector<int>ret;
    if(data.size()<=9){
        int n=data.size();
        for(int i=0;i<n/3;i++){
            ret.push_back(((data[i]+data[n/3+i]+data[2*n/3+i])>=2)?1:0);
        }
    }else{

        /**for(int i=0;i<data.size();i++)cout<<data[i]<<' ';
        cout<<'\n';*/
        int p=7;
        if(data.size()>70)
            p=9;
        int n=data.size()-p;
        int xo=0;
        for(int i=0;i<n;i++) xo^=data[i];
        vector<int>ret;
        if(xo==data[data.size()-1]){
            for(int i=0;i<n;i++){
                ret.push_back(data[i]);
            }
            return  ret;
        }
        int cr=p-1;
        int l=0;

        while(cr>=0&&l<n){
            int i=cr;
            xo=0;
            for(int j=0;j<n;j+=2*(1<<i)){
                for(int k=0;k<(1<<i);k++)
                    if(j+k<n)
                        xo^=data[j+k];
            }

            if(xo==data[n+cr])
                l+=(1<<cr);
            if(cr==0)data[l]=!data[l];
            ///cout<<l<<' '<<xo<<'\n';

            cr--;
        }
        for(int i=0;i<n;i++){
                ret.push_back(data[i]);
        }
        return  ret;


    }
    return ret;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 1092 KB Output is correct
2 Correct 6 ms 876 KB Output is correct
3 Correct 6 ms 1004 KB Output is correct
4 Correct 6 ms 876 KB Output is correct
5 Correct 6 ms 1100 KB Output is correct
6 Correct 6 ms 876 KB Output is correct
7 Correct 6 ms 876 KB Output is correct
8 Correct 6 ms 876 KB Output is correct
9 Correct 5 ms 876 KB Output is correct
10 Correct 6 ms 876 KB Output is correct
11 Correct 6 ms 1100 KB Output is correct
12 Correct 6 ms 1100 KB Output is correct
13 Correct 6 ms 916 KB Output is correct
14 Correct 6 ms 1100 KB Output is correct
15 Correct 6 ms 1100 KB Output is correct
16 Correct 6 ms 876 KB Output is correct
17 Correct 6 ms 876 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 191 ms 2612 KB Output is correct
2 Correct 230 ms 2604 KB Output is correct
3 Correct 195 ms 2596 KB Output is correct
4 Correct 201 ms 2612 KB Output is correct
5 Correct 195 ms 2468 KB Output is correct
6 Correct 191 ms 2644 KB Output is correct
7 Correct 191 ms 2468 KB Output is correct
8 Correct 195 ms 2604 KB Output is correct
9 Correct 195 ms 2596 KB Output is correct
10 Correct 198 ms 2596 KB Output is correct
11 Correct 194 ms 2468 KB Output is correct
12 Correct 193 ms 2596 KB Output is correct
13 Correct 194 ms 2604 KB Output is correct
14 Correct 196 ms 2468 KB Output is correct
15 Correct 195 ms 2468 KB Output is correct
16 Correct 194 ms 2468 KB Output is correct
17 Correct 193 ms 2596 KB Output is correct
18 Correct 198 ms 2612 KB Output is correct
19 Correct 196 ms 2612 KB Output is correct