Submission #623466

# Submission time Handle Problem Language Result Execution time Memory
623466 2022-08-05T16:13:11 Z lcj Data Transfer (IOI19_transfer) C++17
0 / 100
6 ms 2492 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(vector<int> source) {
    int n = source.size();
    int k;
    if (n == 63) {
        k = 6;
    }
    else {
        k = 8;
    }
    k =6;
    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] ^= source[i-1];
            }
        }
    }
    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;
    }
    n = 63;
    k = 6;
    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, 0);
    for (int i = 1; i <= n; i++)
    {
        for (int j = 0; j < k; j++)
        {
            if (i & (1 << j)) {
                at[j] ^= data[i-1];
            }
        }
    }
    int num = 0;
    for (int j = 0; j < k; j++)
    {
        if (data[n+j] != at[j]) {
            num |= (1 << j);
        }
    }
    if (num != 0) data[num-1] ^= 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:51:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   51 |     for (int i = n; i <= data.size(); i++)
      |                     ~~^~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 648 KB WA in grader: wrong source retrieval
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 2492 KB WA in grader: wrong source retrieval
2 Halted 0 ms 0 KB -