답안 #210775

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
210775 2020-03-18T10:42:53 Z Alexa2001 Data Transfer (IOI19_transfer) C++17
100 / 100
228 ms 2928 KB
#include "transfer.h"
#include <bits/stdc++.h>

using namespace std;

vector<int> get_attachment(vector<int> source) 
{
    vector<int> a;
    
    int n;
    if(source.size() < 64) n = 6;
        else n = 8;

    int xor_bits = 0;
    int i, j;
    for(i=0; i<n; ++i)
    {
        int bit = 0;
        for(j=0; j<source.size(); ++j)
            if(!(j & (1<<i))) bit ^= source[j];
        
        a.push_back(bit);
        xor_bits ^= bit;
    }

    a.push_back(xor_bits);
    return a;
}

vector<int> retrieve(vector<int> data) 
{
    int n;
    if(data.size() < 64 + 7) n = 6;
        else n = 8;

    int xor_bits = 0, m = data.size() - n - 1;
    vector<int> b(n), ans;

    int i, j;
    for(i=0; i<n; ++i)
    {
        int bit = 0;
        for(j=0; j<m; ++j)
            if(!(j & (1<<i))) bit ^= data[j];
        b[i] = bit;
    }

    int bad = 0;
    for(i=0; i<n; ++i)
    {
        if(b[i] != data[m + i]) bad |= (1<<i);
        xor_bits ^= data[m + i];
    }
    ans = data;
    ans.resize(m);

    if(bad && xor_bits == data.back()) 
        ans[bad ^ ((1<<n) - 1)] ^= 1; 

    return ans;
}

Compilation message

transfer.cpp: In function 'std::vector<int> get_attachment(std::vector<int>)':
transfer.cpp:19:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for(j=0; j<source.size(); ++j)
                  ~^~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 18 ms 1140 KB Output is correct
2 Correct 16 ms 988 KB Output is correct
3 Correct 17 ms 972 KB Output is correct
4 Correct 16 ms 1028 KB Output is correct
5 Correct 15 ms 976 KB Output is correct
6 Correct 15 ms 1020 KB Output is correct
7 Correct 16 ms 1020 KB Output is correct
8 Correct 15 ms 976 KB Output is correct
9 Correct 16 ms 1232 KB Output is correct
10 Correct 15 ms 1128 KB Output is correct
11 Correct 15 ms 1020 KB Output is correct
12 Correct 15 ms 1132 KB Output is correct
13 Correct 13 ms 1276 KB Output is correct
14 Correct 13 ms 1132 KB Output is correct
15 Correct 15 ms 1136 KB Output is correct
16 Correct 15 ms 1128 KB Output is correct
17 Correct 15 ms 1128 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 222 ms 2664 KB Output is correct
2 Correct 228 ms 2660 KB Output is correct
3 Correct 225 ms 2644 KB Output is correct
4 Correct 221 ms 2928 KB Output is correct
5 Correct 219 ms 2652 KB Output is correct
6 Correct 216 ms 2656 KB Output is correct
7 Correct 216 ms 2656 KB Output is correct
8 Correct 219 ms 2648 KB Output is correct
9 Correct 219 ms 2652 KB Output is correct
10 Correct 214 ms 2608 KB Output is correct
11 Correct 219 ms 2648 KB Output is correct
12 Correct 218 ms 2652 KB Output is correct
13 Correct 221 ms 2652 KB Output is correct
14 Correct 218 ms 2660 KB Output is correct
15 Correct 218 ms 2652 KB Output is correct
16 Correct 217 ms 2508 KB Output is correct
17 Correct 217 ms 2608 KB Output is correct
18 Correct 216 ms 2664 KB Output is correct
19 Correct 215 ms 2656 KB Output is correct