Submission #748191

# Submission time Handle Problem Language Result Execution time Memory
748191 2023-05-25T14:18:44 Z Szil Data Transfer (IOI19_transfer) C++17
100 / 100
1450 ms 2496 KB
    #include "transfer.h"
     
    #include <bits/stdc++.h>
     
    using namespace std;
     
    vector<int> get_attachment(vector<int> source) {
    	vector<int> res;
    	int K = (source.size()<100?6:8);
    	int safe = 0;
    	for (int i = 0; i < K; i++) {
    		int x = 0;
    		int block = 1 << i;
    		for (int j = 0; j < source.size(); j++) {
    			if ((j / block) % 2 == 0) {
    				x ^= source[j];
    			}
    		}
    		res.push_back(x);
    		safe ^= x;
    	}
    	res.push_back(safe);
    	return res;
    }
     
    vector<int> retrieve(vector<int> data) {
    	int n;
    	if (data.size() < 100) {
    		n = 63;
    	} else {
    		n = 255;
    	}
    	int safe = data.back();
    	vector<int> source = vector<int>(data.begin(), data.begin()+n);
    	vector<int> cnt(n);
    	vector<int> v = vector<int>(data.begin()+n, data.end()-1);
    	int K = (source.size()<100?6:8);
    	int p = 0;
    	for (int i : v) p ^= i;
    	if (p != safe) return source;
    	for (int i = 0; i < K; i++) {
    		int x = 0;
    		int block = 1 << i;
    		for (int j = 0; j < n; j++) {
    			if ((j / block) % 2 == 0) {
    				x ^= source[j];
    			}
    		}
    		for (int j = 0; j < n; j++) {
    			if ((j / block) % 2 == (x == v[i])) {
    				cnt[j]++;
    			}
    		}
    	}
    	for (int i = 0; i < n; i++) {
    		if (cnt[i] == K) {
    			source[i] ^= 1;
    			return source;
    		}
    	}
    	return source;
    }

Compilation message

transfer.cpp: In function 'std::vector<int> get_attachment(std::vector<int>)':
transfer.cpp:14:25: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   14 |       for (int j = 0; j < source.size(); j++) {
      |                       ~~^~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 18 ms 644 KB Output is correct
2 Correct 20 ms 644 KB Output is correct
3 Correct 20 ms 648 KB Output is correct
4 Correct 19 ms 808 KB Output is correct
5 Correct 18 ms 648 KB Output is correct
6 Correct 18 ms 716 KB Output is correct
7 Correct 18 ms 644 KB Output is correct
8 Correct 19 ms 792 KB Output is correct
9 Correct 20 ms 736 KB Output is correct
10 Correct 20 ms 664 KB Output is correct
11 Correct 19 ms 656 KB Output is correct
12 Correct 20 ms 736 KB Output is correct
13 Correct 19 ms 740 KB Output is correct
14 Correct 18 ms 644 KB Output is correct
15 Correct 21 ms 644 KB Output is correct
16 Correct 20 ms 728 KB Output is correct
17 Correct 20 ms 652 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1404 ms 2496 KB Output is correct
2 Correct 1428 ms 2488 KB Output is correct
3 Correct 1402 ms 2488 KB Output is correct
4 Correct 1411 ms 2496 KB Output is correct
5 Correct 1450 ms 2472 KB Output is correct
6 Correct 1400 ms 2488 KB Output is correct
7 Correct 1388 ms 2492 KB Output is correct
8 Correct 1390 ms 2488 KB Output is correct
9 Correct 1377 ms 2496 KB Output is correct
10 Correct 1404 ms 2488 KB Output is correct
11 Correct 1400 ms 2356 KB Output is correct
12 Correct 1400 ms 2496 KB Output is correct
13 Correct 1393 ms 2488 KB Output is correct
14 Correct 1396 ms 2420 KB Output is correct
15 Correct 1404 ms 2492 KB Output is correct
16 Correct 1408 ms 2488 KB Output is correct
17 Correct 1407 ms 2488 KB Output is correct
18 Correct 1404 ms 2496 KB Output is correct
19 Correct 1396 ms 2484 KB Output is correct