Submission #1006167

# Submission time Handle Problem Language Result Execution time Memory
1006167 2024-06-23T13:53:36 Z HishamAlshehri Data Transfer (IOI19_transfer) C++17
0 / 100
5 ms 5380 KB
#include <bits/stdc++.h>
using namespace std;

vector<int> get_attachment(vector<int> source) {
	int x = 0, cnt = 0;
	for (int i = 0; i < source.size(); i++)
	{
		if (source[i])
		{
			x ^= i;
			cnt++;
		}
	}
	vector<int>ans = source;
	while (x)
	{
		ans.push_back(x % 2);
		x /= 2;
	}
	ans.push_back(cnt % 2);
	return ans;
}

vector<int> retrieve(vector<int> data) {
	int x1 = 0, k = data[data.size() - 1], cnt = 0;
	int n = (data.size() > 255 ? n = 255 : n = 63);
	for (int i = 0; i < n; i++)
	{
		if (data[i])
		{
			cnt++;
			x1 ^= i;
		}
	}
	int x2 = 0;
	for (int i = n; i < data.size() - 1; i++)
	{
		x2 += data[i] * (1 << (i - n));		
	}
	if (x1 != x2 && cnt % 2 != k)
		data[x2 ^ x1] ^= 1;
	return vector<int>(data.begin(), data.begin() + n);
}

Compilation message

transfer.cpp: In function 'std::vector<int> get_attachment(std::vector<int>)':
transfer.cpp:6:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    6 |  for (int i = 0; i < source.size(); i++)
      |                  ~~^~~~~~~~~~~~~~~
transfer.cpp: In function 'std::vector<int> retrieve(std::vector<int>)':
transfer.cpp:26:33: warning: operation on 'n' may be undefined [-Wsequence-point]
   26 |  int n = (data.size() > 255 ? n = 255 : n = 63);
      |                               ~~^~~~~
transfer.cpp:36:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   36 |  for (int i = n; i < data.size() - 1; i++)
      |                  ~~^~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 1296 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 5 ms 5380 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -