답안 #829887

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
829887 2023-08-18T15:35:26 Z MrDeboo Data Transfer (IOI19_transfer) C++17
100 / 100
600 ms 2536 KB
#include "transfer.h"
#include "bits/stdc++.h"
using namespace std;
std::vector<int> get_attachment(std::vector<int> v) {
	int n=v.size();
	vector<int>voc((n==255?8:6));
	for(int i=1;i<=n;i++){
		for(int w=0;w<voc.size();w++){
			if(i&(1<<w))voc[w]^=v[i-1];
		}
	}
	int g=0;
	for(auto &i:voc)g^=i;
	voc.push_back(g);
	return voc;
}

std::vector<int> retrieve(std::vector<int> v) {
	int nn=(v.size()>100?9:7);
	int n=v.size()-nn;
	int g=0;
	for(int i=v.size()-2;i>=v.size()-nn;i--)g^=v[i];
	if(g!=v.back()){
		for(int i=0;i<nn;i++)v.pop_back();
		return v;
	}
	vector<int>voc(nn-1);
	for(int i=1;i<=n;i++){
		for(int w=0;w<nn-1;w++){
			if(i&(1<<w))voc[w]^=v[i-1];
		}
	}
	int f=0;
	for(int i=0;i<nn-1;i++){
		if(v[i+n]!=voc[i])f++;
	}
	if(f==0){
		for(int i=0;i<nn;i++)v.pop_back();
		return v;
	}
	for(int i=0;i<n;i++){
		int k=0;
		for(int w=0;w<nn-1;w++){
			if((i+1)&(1<<w)){
				if(voc[w]!=v[w+n])k++;
			}
		}
		if(k==f){
			v[i]^=1;
			break;
		}
	}
	for(int i=0;i<nn;i++)v.pop_back();
	return v;
}

Compilation message

transfer.cpp: In function 'std::vector<int> get_attachment(std::vector<int>)':
transfer.cpp:8:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    8 |   for(int w=0;w<voc.size();w++){
      |               ~^~~~~~~~~~~
transfer.cpp: In function 'std::vector<int> retrieve(std::vector<int>)':
transfer.cpp:22:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   22 |  for(int i=v.size()-2;i>=v.size()-nn;i--)g^=v[i];
      |                       ~^~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 640 KB Output is correct
2 Correct 5 ms 724 KB Output is correct
3 Correct 4 ms 724 KB Output is correct
4 Correct 4 ms 724 KB Output is correct
5 Correct 4 ms 648 KB Output is correct
6 Correct 5 ms 728 KB Output is correct
7 Correct 4 ms 640 KB Output is correct
8 Correct 4 ms 648 KB Output is correct
9 Correct 4 ms 648 KB Output is correct
10 Correct 4 ms 720 KB Output is correct
11 Correct 4 ms 640 KB Output is correct
12 Correct 5 ms 640 KB Output is correct
13 Correct 5 ms 720 KB Output is correct
14 Correct 4 ms 728 KB Output is correct
15 Correct 4 ms 648 KB Output is correct
16 Correct 5 ms 640 KB Output is correct
17 Correct 5 ms 648 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 557 ms 2492 KB Output is correct
2 Correct 547 ms 2464 KB Output is correct
3 Correct 573 ms 2492 KB Output is correct
4 Correct 581 ms 2488 KB Output is correct
5 Correct 552 ms 2484 KB Output is correct
6 Correct 600 ms 2476 KB Output is correct
7 Correct 566 ms 2484 KB Output is correct
8 Correct 576 ms 2484 KB Output is correct
9 Correct 569 ms 2484 KB Output is correct
10 Correct 569 ms 2484 KB Output is correct
11 Correct 575 ms 2488 KB Output is correct
12 Correct 553 ms 2488 KB Output is correct
13 Correct 556 ms 2484 KB Output is correct
14 Correct 575 ms 2464 KB Output is correct
15 Correct 572 ms 2536 KB Output is correct
16 Correct 561 ms 2484 KB Output is correct
17 Correct 561 ms 2484 KB Output is correct
18 Correct 549 ms 2480 KB Output is correct
19 Correct 555 ms 2480 KB Output is correct