답안 #210774

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
210774 2020-03-18T10:41:44 Z Alexa2001 Data Transfer (IOI19_transfer) C++17
92 / 100
226 ms 2664 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 = 9;

    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 = 9;

    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 13 ms 996 KB Output is correct
2 Correct 13 ms 1176 KB Output is correct
3 Correct 13 ms 1024 KB Output is correct
4 Correct 15 ms 1136 KB Output is correct
5 Correct 13 ms 1124 KB Output is correct
6 Correct 13 ms 1140 KB Output is correct
7 Correct 13 ms 904 KB Output is correct
8 Correct 15 ms 1024 KB Output is correct
9 Correct 15 ms 1128 KB Output is correct
10 Correct 16 ms 1112 KB Output is correct
11 Correct 15 ms 1128 KB Output is correct
12 Correct 13 ms 1128 KB Output is correct
13 Correct 15 ms 932 KB Output is correct
14 Correct 13 ms 1128 KB Output is correct
15 Correct 15 ms 1128 KB Output is correct
16 Correct 13 ms 1136 KB Output is correct
17 Correct 15 ms 1132 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Partially correct 220 ms 2484 KB Partially correct
2 Partially correct 220 ms 2664 KB Partially correct
3 Partially correct 211 ms 2648 KB Partially correct
4 Partially correct 217 ms 2632 KB Partially correct
5 Partially correct 218 ms 2612 KB Partially correct
6 Partially correct 221 ms 2652 KB Partially correct
7 Partially correct 215 ms 2652 KB Partially correct
8 Partially correct 214 ms 2656 KB Partially correct
9 Partially correct 215 ms 2660 KB Partially correct
10 Partially correct 218 ms 2656 KB Partially correct
11 Partially correct 210 ms 2648 KB Partially correct
12 Partially correct 223 ms 2612 KB Partially correct
13 Partially correct 226 ms 2616 KB Partially correct
14 Partially correct 220 ms 2656 KB Partially correct
15 Partially correct 213 ms 2656 KB Partially correct
16 Partially correct 223 ms 2660 KB Partially correct
17 Partially correct 218 ms 2372 KB Partially correct
18 Partially correct 215 ms 2652 KB Partially correct
19 Partially correct 220 ms 2648 KB Partially correct