Submission #213572

# Submission time Handle Problem Language Result Execution time Memory
213572 2020-03-26T07:45:49 Z _Ice_Tea_ Data Transfer (IOI19_transfer) C++14
92 / 100
348 ms 2976 KB
#include<bits/stdc++.h>
#include "transfer.h"

#define de(x) if( x && x == MODE)
#define MODE 0

using namespace std;

std::vector<int> get_attachment(std::vector<int> source) {

	int i,j,k;

	int N = source.size();
	int L = ( N == 63 ? 6 : 9 );
	// int L = 3;

	vector<int> attach;
	for( i=0; i<L; i++)
	{
		int key = 0;
		for( j=0; j<N; j++)
		{
			if( (j>>i)&1 )
				continue;
			key ^= source[j];
		}
		attach.push_back(key);
	}

	int key = 0;
	for( auto it:attach)
		key ^= it;
	attach.push_back(key);
	de(1)
	{
		printf(">>> ");
		for( auto it:attach)
			printf("%d ", it);
		printf("\n");
	}

	return attach;
}

std::vector<int> retrieve(std::vector<int> data) {

	int i,j;

	int N = ( data.size() == 70 ? 63 : 255);
	// int N = 7;
	int L = data.size() - N - 1;

	vector<int> ans;
	int arr[256];

	int idx = 0;
	for( i=0; i<L; i++)
	{
		int key = 0;
		for( j=0; j<N; j++)
		{
			if( (j>>i)&1 )
				continue;
			key ^= data[j];
		}

		if( key == data[ N+i ])
			idx ^= (1<<i);
	}

	de(1) printf("idx = %d\n", idx);

	for( i=0; i<N; i++)
		ans.push_back( data[i] );
	if( idx == N)
	{
		// return ans;
	}
	else
	{
		int key = 0;
		for( i=0; i<L; i++)
			key ^= data[ N+i ];

		if( key != data.back())
		{
			// return ans;
		}
		else
		{
			ans[idx] ^= 1;
			// return ans;
		}
	}

	de(1)
	{
		printf("ans = ");
		for( auto it: ans)
			printf("%d", it);
		printf("\n");
	}
	return ans;
}

Compilation message

transfer.cpp: In function 'std::vector<int> get_attachment(std::vector<int>)':
transfer.cpp:11:10: warning: unused variable 'k' [-Wunused-variable]
  int i,j,k;
          ^
transfer.cpp: In function 'std::vector<int> retrieve(std::vector<int>)':
transfer.cpp:54:6: warning: unused variable 'arr' [-Wunused-variable]
  int arr[256];
      ^~~
# Verdict Execution time Memory Grader output
1 Correct 16 ms 996 KB Output is correct
2 Correct 15 ms 1156 KB Output is correct
3 Correct 17 ms 1128 KB Output is correct
4 Correct 19 ms 1040 KB Output is correct
5 Correct 16 ms 1128 KB Output is correct
6 Correct 16 ms 1040 KB Output is correct
7 Correct 17 ms 1148 KB Output is correct
8 Correct 18 ms 1148 KB Output is correct
9 Correct 17 ms 1040 KB Output is correct
10 Correct 16 ms 1148 KB Output is correct
11 Correct 16 ms 1024 KB Output is correct
12 Correct 18 ms 1168 KB Output is correct
13 Correct 17 ms 992 KB Output is correct
14 Correct 19 ms 1040 KB Output is correct
15 Correct 16 ms 1144 KB Output is correct
16 Correct 17 ms 1116 KB Output is correct
17 Correct 15 ms 1152 KB Output is correct
# Verdict Execution time Memory Grader output
1 Partially correct 334 ms 2644 KB Partially correct
2 Partially correct 330 ms 2668 KB Partially correct
3 Partially correct 336 ms 2676 KB Partially correct
4 Partially correct 324 ms 2680 KB Partially correct
5 Partially correct 348 ms 2976 KB Partially correct
6 Partially correct 330 ms 2628 KB Partially correct
7 Partially correct 329 ms 2628 KB Partially correct
8 Partially correct 331 ms 2668 KB Partially correct
9 Partially correct 328 ms 2628 KB Partially correct
10 Partially correct 325 ms 2672 KB Partially correct
11 Partially correct 324 ms 2668 KB Partially correct
12 Partially correct 330 ms 2648 KB Partially correct
13 Partially correct 329 ms 2668 KB Partially correct
14 Partially correct 321 ms 2668 KB Partially correct
15 Partially correct 323 ms 2664 KB Partially correct
16 Partially correct 324 ms 2668 KB Partially correct
17 Partially correct 330 ms 2796 KB Partially correct
18 Partially correct 327 ms 2676 KB Partially correct
19 Partially correct 325 ms 2668 KB Partially correct