Submission #623464

# Submission time Handle Problem Language Result Execution time Memory
623464 2022-08-05T16:08:27 Z lcj Data Transfer (IOI19_transfer) C++17
40 / 100
274 ms 2588 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;
    }
    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;
    }
    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: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++)
      |                     ~~^~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 640 KB WA in grader: wrong source retrieval
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 258 ms 2516 KB Output is correct
2 Correct 255 ms 2492 KB Output is correct
3 Correct 238 ms 2504 KB Output is correct
4 Correct 256 ms 2492 KB Output is correct
5 Correct 245 ms 2492 KB Output is correct
6 Correct 251 ms 2496 KB Output is correct
7 Correct 240 ms 2492 KB Output is correct
8 Correct 252 ms 2492 KB Output is correct
9 Correct 251 ms 2588 KB Output is correct
10 Correct 274 ms 2492 KB Output is correct
11 Correct 241 ms 2500 KB Output is correct
12 Correct 245 ms 2476 KB Output is correct
13 Correct 251 ms 2496 KB Output is correct
14 Correct 247 ms 2500 KB Output is correct
15 Correct 248 ms 2500 KB Output is correct
16 Correct 242 ms 2496 KB Output is correct
17 Correct 242 ms 2492 KB Output is correct
18 Correct 244 ms 2500 KB Output is correct
19 Correct 245 ms 2492 KB Output is correct