Submission #623468

# Submission time Handle Problem Language Result Execution time Memory
623468 2022-08-05T16:21:26 Z lcj Data Transfer (IOI19_transfer) C++17
100 / 100
240 ms 2496 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"

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 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 Correct 4 ms 644 KB Output is correct
2 Correct 4 ms 652 KB Output is correct
3 Correct 4 ms 656 KB Output is correct
4 Correct 3 ms 732 KB Output is correct
5 Correct 5 ms 748 KB Output is correct
6 Correct 4 ms 652 KB Output is correct
7 Correct 4 ms 644 KB Output is correct
8 Correct 5 ms 772 KB Output is correct
9 Correct 4 ms 652 KB Output is correct
10 Correct 5 ms 736 KB Output is correct
11 Correct 5 ms 652 KB Output is correct
12 Correct 4 ms 644 KB Output is correct
13 Correct 4 ms 652 KB Output is correct
14 Correct 4 ms 644 KB Output is correct
15 Correct 3 ms 644 KB Output is correct
16 Correct 5 ms 640 KB Output is correct
17 Correct 3 ms 652 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 237 ms 2492 KB Output is correct
2 Correct 235 ms 2496 KB Output is correct
3 Correct 233 ms 2492 KB Output is correct
4 Correct 237 ms 2496 KB Output is correct
5 Correct 233 ms 2492 KB Output is correct
6 Correct 236 ms 2484 KB Output is correct
7 Correct 232 ms 2484 KB Output is correct
8 Correct 234 ms 2496 KB Output is correct
9 Correct 233 ms 2496 KB Output is correct
10 Correct 229 ms 2496 KB Output is correct
11 Correct 233 ms 2484 KB Output is correct
12 Correct 237 ms 2492 KB Output is correct
13 Correct 230 ms 2484 KB Output is correct
14 Correct 235 ms 2484 KB Output is correct
15 Correct 230 ms 2492 KB Output is correct
16 Correct 234 ms 2488 KB Output is correct
17 Correct 237 ms 2492 KB Output is correct
18 Correct 240 ms 2492 KB Output is correct
19 Correct 239 ms 2492 KB Output is correct