Submission #308002

# Submission time Handle Problem Language Result Execution time Memory
308002 2020-09-29T17:52:41 Z kimjg1119 Data Transfer (IOI19_transfer) C++17
80 / 100
346 ms 2672 KB
#include "transfer.h"
#include <bits/stdc++.h>

using namespace std;

vector<int> get_attachment_sub1(vector<int> sc) {
	int a[10] = {};
	for (int i = 0; i < sc.size(); i++) {
		for (int j = 0; j < 6; j++)
			if(sc[i]) a[j] ^= (i + 1) & (1 << j);
	}
	vector<int> r;
	for (int i = 0; i < 6; i++)
		if (a[i]) r.push_back(1);
		else r.push_back(0);
	
	vector<int> at;
	for (int i = 0; i < 2; i++) {
		for (int j = 0; j < 6; j++)
			at.push_back(r[j]);
	}
	return at;
}

vector<int> get_attachment_sub2(vector<int> sc) {
	int a[10] = {};
	for (int i = 0; i < sc.size(); i++) {
		for (int j = 0; j < 8; j++)
			if (sc[i]) a[j] ^= (i + 1) & (1 << j);
	}
	vector<int> r;
	for (int i = 0; i < 8; i++)
		if (a[i]) r.push_back(1);
		else r.push_back(0);

	vector<int> at;
	for (int i = 0; i < 2; i++) {
		for (int j = 0; j < 8; j++)
			at.push_back(r[j]);
	}
	return at;
}

std::vector<int> get_attachment(std::vector<int> source) {
	if (source.size() == 63) return get_attachment_sub1(source);
	else return get_attachment_sub2(source);
}

vector<int> retrieve_sub1(vector<int> d) {
	vector<int> t, t1, t2;
	for (int i = 63; i < d.size(); i++) t.push_back(d[i]);
	for (int i = 0; i < 12; i++) d.pop_back();
	for (int i = 0; i < 6; i++) t1.push_back(t[i]);
	for (int i = 0; i < 6; i++) t2.push_back(t[i + 6]);

	bool flag = true;
	for (int i = 0; i < 6; i++)
		if (t1[i] != t2[i]) flag = false;
	if (flag) {
		int a[10] = {};
		for (int i = 0; i < d.size(); i++) {
			for (int j = 0; j < 6; j++)
				if (d[i]) a[j] ^= (i+1) & (1 << j);
		}
		int r = 0;
		for (int i = 0; i < 6; i++) a[i] ^= t1[i] * (1<<i);
		for (int i = 0; i < 6; i++)
			if (a[i]) r |= (1 << i);
		if (r > 0) d[r - 1] = 1 - d[r - 1];
		return d;
	}
	else return d;
}

vector<int> retrieve_sub2(vector<int> d) {
	vector<int> t, t1, t2;
	for (int i = 255; i < d.size(); i++) t.push_back(d[i]);
	for (int i = 0; i < 16; i++) d.pop_back();
	for (int i = 0; i < 8; i++) t1.push_back(t[i]);
	for (int i = 0; i < 8; i++) t2.push_back(t[i + 8]);

	bool flag = true;
	for (int i = 0; i < 8; i++)
		if (t1[i] != t2[i]) flag = false;
	if (flag) {
		int a[10] = {};
		for (int i = 0; i < d.size(); i++) {
			for (int j = 0; j < 8; j++)
				if (d[i]) a[j] ^= (i + 1) & (1 << j);
		}
		int r = 0;
		for (int i = 0; i < 8; i++) a[i] ^= t1[i] * (1 << i);
		for (int i = 0; i < 8; i++)
			if (a[i]) r |= (1 << i);
		if (r > 0) d[r - 1] = 1 - d[r - 1];
		return d;
	}
	else return d;
}

std::vector<int> retrieve(std::vector<int> data) {
	if (data.size() < 255) return retrieve_sub1(data);
	else return retrieve_sub2(data);
}

Compilation message

transfer.cpp: In function 'std::vector<int> get_attachment_sub1(std::vector<int>)':
transfer.cpp:8:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    8 |  for (int i = 0; i < sc.size(); i++) {
      |                  ~~^~~~~~~~~~~
transfer.cpp: In function 'std::vector<int> get_attachment_sub2(std::vector<int>)':
transfer.cpp:27:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   27 |  for (int i = 0; i < sc.size(); i++) {
      |                  ~~^~~~~~~~~~~
transfer.cpp: In function 'std::vector<int> retrieve_sub1(std::vector<int>)':
transfer.cpp:51:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   51 |  for (int i = 63; i < d.size(); i++) t.push_back(d[i]);
      |                   ~~^~~~~~~~~~
transfer.cpp:61:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   61 |   for (int i = 0; i < d.size(); i++) {
      |                   ~~^~~~~~~~~~
transfer.cpp: In function 'std::vector<int> retrieve_sub2(std::vector<int>)':
transfer.cpp:77:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   77 |  for (int i = 255; i < d.size(); i++) t.push_back(d[i]);
      |                    ~~^~~~~~~~~~
transfer.cpp:87:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   87 |   for (int i = 0; i < d.size(); i++) {
      |                   ~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Partially correct 9 ms 1152 KB Partially correct
2 Partially correct 9 ms 1036 KB Partially correct
3 Partially correct 9 ms 908 KB Partially correct
4 Partially correct 9 ms 1148 KB Partially correct
5 Partially correct 9 ms 908 KB Partially correct
6 Partially correct 9 ms 1152 KB Partially correct
7 Partially correct 9 ms 1152 KB Partially correct
8 Partially correct 9 ms 908 KB Partially correct
9 Partially correct 9 ms 1144 KB Partially correct
10 Partially correct 8 ms 908 KB Partially correct
11 Partially correct 9 ms 1152 KB Partially correct
12 Partially correct 9 ms 1036 KB Partially correct
13 Partially correct 9 ms 1144 KB Partially correct
14 Partially correct 9 ms 908 KB Partially correct
15 Partially correct 9 ms 1140 KB Partially correct
16 Partially correct 9 ms 908 KB Partially correct
17 Partially correct 9 ms 1036 KB Partially correct
# Verdict Execution time Memory Grader output
1 Partially correct 279 ms 2500 KB Partially correct
2 Partially correct 278 ms 2660 KB Partially correct
3 Partially correct 281 ms 2664 KB Partially correct
4 Partially correct 303 ms 2628 KB Partially correct
5 Partially correct 323 ms 2664 KB Partially correct
6 Partially correct 346 ms 2668 KB Partially correct
7 Partially correct 308 ms 2500 KB Partially correct
8 Partially correct 257 ms 2664 KB Partially correct
9 Partially correct 233 ms 2672 KB Partially correct
10 Partially correct 241 ms 2668 KB Partially correct
11 Partially correct 229 ms 2668 KB Partially correct
12 Partially correct 317 ms 2664 KB Partially correct
13 Partially correct 267 ms 2652 KB Partially correct
14 Partially correct 284 ms 2664 KB Partially correct
15 Partially correct 269 ms 2664 KB Partially correct
16 Partially correct 264 ms 2660 KB Partially correct
17 Partially correct 272 ms 2660 KB Partially correct
18 Partially correct 264 ms 2664 KB Partially correct
19 Partially correct 261 ms 2664 KB Partially correct