Submission #941627

# Submission time Handle Problem Language Result Execution time Memory
941627 2024-03-09T08:10:05 Z benjaminkleyn Data Transfer (IOI19_transfer) C++17
100 / 100
148 ms 2544 KB
#include <bits/stdc++.h>
#include "transfer.h"
using namespace std;

vector<int> get_attachment(vector<int> source) 
{
    int K = (source.size() < 100 ? 7 : 9);
    vector<int> attachment;
    int x = 0;
    for (int i = 0; i < source.size(); i++)
        x ^= source[i];
    source.push_back(x);
    attachment.push_back(x);
    for (int k = 0; k < K - 1; k++)
    {
        x = 0;
        for (int i = 0; i < source.size(); i++)
            if (i & (1 << k))
                x ^= source[i];
        attachment.push_back(x);
    }
    return attachment;
}

vector<int> retrieve(vector<int> data) 
{
    int K = (data.size() < 100 ? 7 : 9);
    vector<int> attachment(data.end() - (K - 1), data.end());
	data = vector<int>(data.begin(), data.end() - (K - 1));
    int x = 0;
    for (int i = 0; i < data.size(); i++) 
        x ^= data[i];
    if (x == 0)
    {
        data.pop_back();
        return data;
    }
    int result = 0;
    for (int k = 0; k < K - 1; k++)
    {
        x = attachment[k];
        for (int i = 0; i < data.size(); i++)
            if (i & (1 << k))
                x ^= data[i];
        if (x)
            result ^= (1 << k);
    }
    data[result] ^= 1;
    data.pop_back();
    return data;
}

Compilation message

transfer.cpp: In function 'std::vector<int> get_attachment(std::vector<int>)':
transfer.cpp:10:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   10 |     for (int i = 0; i < source.size(); i++)
      |                     ~~^~~~~~~~~~~~~~~
transfer.cpp:17:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   17 |         for (int i = 0; i < source.size(); i++)
      |                         ~~^~~~~~~~~~~~~~~
transfer.cpp: In function 'std::vector<int> retrieve(std::vector<int>)':
transfer.cpp:31:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   31 |     for (int i = 0; i < data.size(); i++)
      |                     ~~^~~~~~~~~~~~~
transfer.cpp:42:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   42 |         for (int i = 0; i < data.size(); i++)
      |                         ~~^~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 3 ms 800 KB Output is correct
2 Correct 2 ms 792 KB Output is correct
3 Correct 3 ms 792 KB Output is correct
4 Correct 4 ms 792 KB Output is correct
5 Correct 3 ms 792 KB Output is correct
6 Correct 3 ms 800 KB Output is correct
7 Correct 3 ms 800 KB Output is correct
8 Correct 3 ms 792 KB Output is correct
9 Correct 3 ms 796 KB Output is correct
10 Correct 3 ms 800 KB Output is correct
11 Correct 4 ms 784 KB Output is correct
12 Correct 3 ms 1232 KB Output is correct
13 Correct 3 ms 792 KB Output is correct
14 Correct 3 ms 800 KB Output is correct
15 Correct 3 ms 792 KB Output is correct
16 Correct 3 ms 800 KB Output is correct
17 Correct 4 ms 800 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 129 ms 2516 KB Output is correct
2 Correct 134 ms 2516 KB Output is correct
3 Correct 145 ms 2504 KB Output is correct
4 Correct 133 ms 2508 KB Output is correct
5 Correct 136 ms 2512 KB Output is correct
6 Correct 138 ms 2512 KB Output is correct
7 Correct 126 ms 2512 KB Output is correct
8 Correct 133 ms 2516 KB Output is correct
9 Correct 141 ms 2516 KB Output is correct
10 Correct 139 ms 2544 KB Output is correct
11 Correct 136 ms 2504 KB Output is correct
12 Correct 148 ms 2508 KB Output is correct
13 Correct 132 ms 2508 KB Output is correct
14 Correct 144 ms 2516 KB Output is correct
15 Correct 128 ms 2512 KB Output is correct
16 Correct 130 ms 2520 KB Output is correct
17 Correct 135 ms 2516 KB Output is correct
18 Correct 132 ms 2516 KB Output is correct
19 Correct 142 ms 2508 KB Output is correct