답안 #623451

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
623451 2022-08-05T15:45:30 Z lcj Data Transfer (IOI19_transfer) C++17
0 / 100
7 ms 2472 KB
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;

#include "transfer.h"

std::vector<int> get_attachment(std::vector<int> source) {
    int n = source.size();
    int k;
    if (n == 63) {
        k = 6;
    }
    else {
        k = 8;
    }
    vector<int> at(k+1, 0);
    for (int i = 1; i <= n; i++)
    {
        for (int j = 0; j < k; j++)
        {
            if (i & (1 << j)) {
                at[j] ^= (bool)(source[i-1] & (1 << j));
            }
        }
    }
    for (int i = 0; i < k; i++)
    {
        at[k] ^= at[i];
    }
	return at;
}

std::vector<int> retrieve(std::vector<int> data) {
    int n, k;
    if (data.size() == 70) {
        n = 63;
        k = 6;
    }
    else {
        n = 255;
        k = 8;
    }
    int cxor = 0;
    for (int i = n; i <= data.size(); i++)
    {
        cxor ^= data[i];
    }
    if (cxor) {
        return vector<int>(data.begin(), data.begin()+n);
    }
    vector<int> at(k+1, 0);
    for (int i = 1; i <= n; i++)
    {
        for (int j = 0; j < k; j++)
        {
            if (i & (1 << j)) {
                at[j] ^= (bool)(data[i-1] & (1 << j));
            }
        }
    }
    int num = 0;
    for (int j = 0; j < k; j++)
    {
        if (data[n+j] != at[j]) {
            num |= (1 << j);
        }
    }
    data[num] ^= 1;
	return std::vector<int>(data.begin(), data.begin()+n);
}

Compilation message

transfer.cpp: In function 'std::vector<int> retrieve(std::vector<int>)':
transfer.cpp:48:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   48 |     for (int i = n; i <= data.size(); i++)
      |                     ~~^~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 4 ms 784 KB WA in grader: wrong source retrieval
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 7 ms 2472 KB WA in grader: wrong source retrieval
2 Halted 0 ms 0 KB -