답안 #143622

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
143622 2019-08-14T18:32:21 Z zoomswk Data Transfer (IOI19_transfer) C++17
100 / 100
716 ms 2716 KB
#include "transfer.h"
using namespace std;

vector<int> get_attachment(vector<int> source) {
    int n = (int)source.size();
    vector<int> ret;
    int tmp = 0;
    for(int i=0; i<n; i++) tmp ^= source[i];
    ret.push_back(tmp);
    source.push_back(tmp);
    int bits = 6;
    if(n == 255) bits = 8;
    for(int i=1; i<=bits; i++){
        int tmp = 0;
        for(int j=0; j<=n; j++){
            if((j%(1<<i)) >= (1<<i)/2) tmp ^= source[j];
        }
        ret.push_back(tmp);
    }
    return ret;
}

vector<int> retrieve(vector<int> data) {
    vector<int> ret;
    int n = (int)data.size();
    int bits = 6;
    if(n == 255+9) bits = 8;
    n -= bits;
    int faulty = 0;
    for(int i=1; i<=bits; i++){
        int tmp = 0;
        for(int j=0; j<n; j++){
            if((j%(1<<i)) >= (1<<i)/2) tmp ^= data[j];
        }
        if(tmp != data[n+i-1]) faulty += (1<<(i-1));
    }
    for(int i=0; i<n-1; i++) ret.push_back(data[i]);
    if(faulty != n-1){
        int tmp = 0;
        for(int i=0; i<n-1; i++) tmp ^= data[i];
        if(tmp != data[n-1]){
            ret[faulty] ^= 1;
        }
    }
    return ret;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 15 ms 1024 KB Output is correct
2 Correct 15 ms 888 KB Output is correct
3 Correct 15 ms 1092 KB Output is correct
4 Correct 15 ms 888 KB Output is correct
5 Correct 15 ms 1024 KB Output is correct
6 Correct 15 ms 1020 KB Output is correct
7 Correct 15 ms 976 KB Output is correct
8 Correct 15 ms 1016 KB Output is correct
9 Correct 15 ms 896 KB Output is correct
10 Correct 15 ms 888 KB Output is correct
11 Correct 15 ms 1024 KB Output is correct
12 Correct 15 ms 984 KB Output is correct
13 Correct 15 ms 1024 KB Output is correct
14 Correct 15 ms 980 KB Output is correct
15 Correct 16 ms 1028 KB Output is correct
16 Correct 15 ms 1144 KB Output is correct
17 Correct 15 ms 976 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 703 ms 2716 KB Output is correct
2 Correct 716 ms 2612 KB Output is correct
3 Correct 704 ms 2648 KB Output is correct
4 Correct 707 ms 2612 KB Output is correct
5 Correct 703 ms 2604 KB Output is correct
6 Correct 707 ms 2652 KB Output is correct
7 Correct 703 ms 2476 KB Output is correct
8 Correct 715 ms 2604 KB Output is correct
9 Correct 705 ms 2620 KB Output is correct
10 Correct 703 ms 2624 KB Output is correct
11 Correct 707 ms 2604 KB Output is correct
12 Correct 706 ms 2612 KB Output is correct
13 Correct 715 ms 2604 KB Output is correct
14 Correct 716 ms 2624 KB Output is correct
15 Correct 703 ms 2628 KB Output is correct
16 Correct 703 ms 2608 KB Output is correct
17 Correct 706 ms 2604 KB Output is correct
18 Correct 708 ms 2612 KB Output is correct
19 Correct 710 ms 2612 KB Output is correct