답안 #339687

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
339687 2020-12-25T23:28:56 Z ogibogi2004 Data Transfer (IOI19_transfer) C++14
100 / 100
146 ms 2720 KB
#include "transfer.h"
#include <bits/stdc++.h>
using namespace std;
vector<int> get_attachment(vector<int> source) {
	int xr=0,cnt=0;
	for(int i=0;i<source.size();i++)
	{
		if(source[i]==1)xr^=(i+1),cnt++;
	}
	vector<int>k;
	if(source.size()==255)
	{
		for(int i=0;i<8;i++)
		{
			if(xr&(1<<i))k.push_back(1);
			else k.push_back(0);
		}
	}
	else
	{
		for(int i=0;i<6;i++)
		{
			if(xr&(1<<i))k.push_back(1);
			else k.push_back(0);
		}
	}
	k.push_back(cnt%2);
	return k;
}

vector<int> retrieve(vector<int> data) {
	vector<int>ret;
	int xr1=0,xr2=0,cnt=0;
	if(data.size()>200)
	{
		for(int i=0;i<data.size()-9;i++)
		{
			ret.push_back(data[i]);
			if(data[i]==1)
			{
				xr1^=(i+1);cnt++;
			}
		}
		for(int i=data.size()-9;i<data.size()-1;i++)
		{
			if(data[i]==1)
			{
				xr2|=(1<<(i-data.size()+9));
			}
		}
	}
	else
	{
		for(int i=0;i<data.size()-7;i++)
		{
			ret.push_back(data[i]);
			if(data[i]==1)
			{
				xr1^=(i+1);cnt++;
			}
		}
		for(int i=data.size()-7;i<data.size()-1;i++)
		{
			if(data[i]==1)
			{
				xr2|=(1<<(i-data.size()+7));
			}
		}
	}
	if(cnt%2==data.back())
	{
		return ret;
	}
	if((xr1^xr2)==0)return ret;
	ret[(xr1^xr2)-1]^=1;
	return ret;
}

Compilation message

transfer.cpp: In function 'std::vector<int> get_attachment(std::vector<int>)':
transfer.cpp:6:15: 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:36:16: 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=0;i<data.size()-9;i++)
      |               ~^~~~~~~~~~~~~~
transfer.cpp:44:28: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   44 |   for(int i=data.size()-9;i<data.size()-1;i++)
      |                           ~^~~~~~~~~~~~~~
transfer.cpp:54:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   54 |   for(int i=0;i<data.size()-7;i++)
      |               ~^~~~~~~~~~~~~~
transfer.cpp:62:28: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   62 |   for(int i=data.size()-7;i<data.size()-1;i++)
      |                           ~^~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 1140 KB Output is correct
2 Correct 5 ms 876 KB Output is correct
3 Correct 6 ms 1092 KB Output is correct
4 Correct 4 ms 876 KB Output is correct
5 Correct 5 ms 876 KB Output is correct
6 Correct 5 ms 1092 KB Output is correct
7 Correct 5 ms 1004 KB Output is correct
8 Correct 5 ms 876 KB Output is correct
9 Correct 5 ms 1132 KB Output is correct
10 Correct 6 ms 876 KB Output is correct
11 Correct 4 ms 876 KB Output is correct
12 Correct 5 ms 876 KB Output is correct
13 Correct 5 ms 992 KB Output is correct
14 Correct 5 ms 1044 KB Output is correct
15 Correct 5 ms 1100 KB Output is correct
16 Correct 5 ms 1100 KB Output is correct
17 Correct 5 ms 1092 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 119 ms 2552 KB Output is correct
2 Correct 138 ms 2720 KB Output is correct
3 Correct 119 ms 2464 KB Output is correct
4 Correct 120 ms 2604 KB Output is correct
5 Correct 121 ms 2464 KB Output is correct
6 Correct 115 ms 2604 KB Output is correct
7 Correct 115 ms 2508 KB Output is correct
8 Correct 114 ms 2604 KB Output is correct
9 Correct 139 ms 2604 KB Output is correct
10 Correct 146 ms 2464 KB Output is correct
11 Correct 113 ms 2648 KB Output is correct
12 Correct 121 ms 2592 KB Output is correct
13 Correct 122 ms 2464 KB Output is correct
14 Correct 118 ms 2592 KB Output is correct
15 Correct 116 ms 2592 KB Output is correct
16 Correct 118 ms 2464 KB Output is correct
17 Correct 120 ms 2592 KB Output is correct
18 Correct 117 ms 2464 KB Output is correct
19 Correct 133 ms 2604 KB Output is correct