Submission #818896

# Submission time Handle Problem Language Result Execution time Memory
818896 2023-08-10T07:14:18 Z LIF Data Transfer (IOI19_transfer) C++14
80 / 100
96 ms 2560 KB
#include "transfer.h"
#include<bits/stdc++.h>
using namespace std;
int n;
vector<int> get_attachment(vector<int> source)
{
	int ans = 0;
	n = source.size();
	int need = 0;
	int mul = 1;
	if(n == 63) need = 7;
	else need = 9;
	//cout<<n<<endl;
	//cout<<need<<endl;
	for(int i=0;i<source.size();i++)if(source[i] == 1)ans ^= (i+1);
	vector<int> temp;
	for(int i=0;i<need;i++)temp.push_back(0);
	int nowbit = 0;
	//cout<<ans<<endl;
	while(ans > 0)
	{
		if(ans %2 == 0)temp[nowbit] = 0;
		else temp[nowbit] = 1;
		nowbit++;
		ans /= 2;
	}
	int kk = 0;
	vector<int> add;
	/*for(int i=temp.size()-1;i>=0;i--)cout<<temp[i]<<" ";
	cout<<endl;*/
	for(int i=temp.size()-1;i>=0;i--)add.push_back(temp[i]);
	for(int i=0;i<add.size();i++)kk ^= add[i];
	add.push_back(kk);
	/*for(int i=0;i<add.size();i++)cout<<add[i]<<" ";
	cout<<endl;*/
	/*for(int i=0;i<source.size();i++)cout<<source[i]<<" ";
	cout<<endl;*/
	return add;
}
vector<int> retrieve(vector<int> data)
{
	/*cout<<data.size()<<endl;
	cout<<"data: ";*/
/*	for(int i=n;i<data.size();i++)cout<<data[i];
	cout<<endl;*/
	int temp = 0;
	int n;
	if(data.size() == 71) n = 63;
	else n = 255;
	for(int i=n;i<data.size()-1;i++)temp ^= data[i];
	if(temp == data[data.size()-1]) // the part of ans1 has been changed.
	{
		int suxor = 0;
		int nowbit = 1;
		for(int i=data.size()-2;i>=n;i--)
		{
			if(data[i] == 1)suxor += nowbit;
			nowbit *= 2;
		}
	//	cout<<suxor<<endl;
		int temp2 = 0;
		for(int i=0;i<n;i++)if(data[i] == 1)temp2 ^= (i+1);
		if(suxor == temp2)
		{
			vector<int> ans;
			ans.clear();
			for(int i=0;i<n;i++)ans.push_back(data[i]);
			return ans;
		}
		else
		{
			int change = (suxor^temp2);
			data[change-1] ^=1;
			vector<int> ans;
			ans.clear();
			for(int i=0;i<n;i++)ans.push_back(data[i]);
			return ans;
		}
	}
	else
	{
		vector<int> ans;
		ans.clear();
		for(int i=0;i<n;i++)ans.push_back(data[i]);
		return ans;
	}
}

Compilation message

transfer.cpp: In function 'std::vector<int> get_attachment(std::vector<int>)':
transfer.cpp:15:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   15 |  for(int i=0;i<source.size();i++)if(source[i] == 1)ans ^= (i+1);
      |              ~^~~~~~~~~~~~~~
transfer.cpp:32:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   32 |  for(int i=0;i<add.size();i++)kk ^= add[i];
      |              ~^~~~~~~~~~~
transfer.cpp:10:6: warning: unused variable 'mul' [-Wunused-variable]
   10 |  int mul = 1;
      |      ^~~
transfer.cpp: In function 'std::vector<int> retrieve(std::vector<int>)':
transfer.cpp:50:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   50 |  for(int i=n;i<data.size()-1;i++)temp ^= data[i];
      |              ~^~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Partially correct 3 ms 640 KB Partially correct
2 Partially correct 4 ms 644 KB Partially correct
3 Partially correct 2 ms 652 KB Partially correct
4 Partially correct 3 ms 644 KB Partially correct
5 Partially correct 3 ms 716 KB Partially correct
6 Partially correct 4 ms 644 KB Partially correct
7 Partially correct 3 ms 736 KB Partially correct
8 Partially correct 2 ms 732 KB Partially correct
9 Partially correct 3 ms 644 KB Partially correct
10 Partially correct 3 ms 644 KB Partially correct
11 Partially correct 3 ms 652 KB Partially correct
12 Partially correct 3 ms 732 KB Partially correct
13 Partially correct 3 ms 652 KB Partially correct
14 Partially correct 5 ms 728 KB Partially correct
15 Partially correct 5 ms 644 KB Partially correct
16 Partially correct 3 ms 732 KB Partially correct
17 Partially correct 3 ms 644 KB Partially correct
# Verdict Execution time Memory Grader output
1 Partially correct 59 ms 2484 KB Partially correct
2 Partially correct 88 ms 2404 KB Partially correct
3 Partially correct 60 ms 2488 KB Partially correct
4 Partially correct 66 ms 2508 KB Partially correct
5 Partially correct 96 ms 2424 KB Partially correct
6 Partially correct 68 ms 2488 KB Partially correct
7 Partially correct 68 ms 2460 KB Partially correct
8 Partially correct 79 ms 2452 KB Partially correct
9 Partially correct 67 ms 2488 KB Partially correct
10 Partially correct 59 ms 2532 KB Partially correct
11 Partially correct 60 ms 2464 KB Partially correct
12 Partially correct 59 ms 2488 KB Partially correct
13 Partially correct 61 ms 2496 KB Partially correct
14 Partially correct 75 ms 2460 KB Partially correct
15 Partially correct 86 ms 2488 KB Partially correct
16 Partially correct 63 ms 2560 KB Partially correct
17 Partially correct 65 ms 2500 KB Partially correct
18 Partially correct 69 ms 2448 KB Partially correct
19 Partially correct 91 ms 2492 KB Partially correct