답안 #829827

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
829827 2023-08-18T15:16:05 Z MrDeboo Data Transfer (IOI19_transfer) C++17
컴파일 오류
0 ms 0 KB
#include "transfer.h"
#include "bits/stdc++.h"
using namespace std;
std::vector<int> get_attachment(std::vector<int> v) {
	n=v.size();
	vector<int>voc((n==255?8:6));
	for(int i=1;i<=n;i++){
		for(int w=0;w<8;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=(n>100?9:7);
	int n=v.size()-nn;
	int g=0;
	for(int i=v.size()-1;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++;
	}
	for(int i=0;i<n;i++){
		int k=0;
		for(int w=0;w<nn-1;w++){
			if(i&(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:5:2: error: 'n' was not declared in this scope
    5 |  n=v.size();
      |  ^
transfer.cpp: In function 'std::vector<int> retrieve(std::vector<int>)':
transfer.cpp:19:10: error: 'n' was not declared in this scope; did you mean 'nn'?
   19 |  int nn=(n>100?9:7);
      |          ^
      |          nn
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()-1;i>=v.size()-nn;i--)g^=v[i];
      |                       ~^~~~~~~~~~~~~