답안 #434568

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
434568 2021-06-21T12:12:11 Z egekabas Data Transfer (IOI19_transfer) C++14
0 / 100
4 ms 972 KB
#include <bits/stdc++.h>
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

std::vector<int> get_attachment(std::vector<int> source) {
	int n = source.size(), k;
	if(n == 63)
		k = 7;
	else{
		k = 9;
		assert(0);
	}
	
	vector<int> ret(k);
	for(int i = 0; i < n; ++i){
		for(int j = 0; j < (k-1); ++j)
			if((1<<j)&i)
				ret[j] ^= source[i];
		ret[k-1] ^= source[i];
	}
	return ret;
}

std::vector<int> retrieve(std::vector<int> data) {
	int n, k;
	if(data.size() == 70){
		n = 63, k = 7;
	}
	else{
		assert(0);
		n = 255, k = 9;
	}
	vector<int> ori(data.begin(), data.begin()+n);
	int tot = data.back();
	
	vector<vector<int>> vals(2, vector<int>(k-1));
	vals[1] = vector<int>(data.begin()+n, data.end()-1);
	for(int i = 0; i < k-1; ++i)
		vals[0][i] = vals[1][i]^tot;

	vector<vector<int>> cur(2, vector<int>(k-1));
	for(int i = 0; i < n; ++i)
		for(int j = 0; j < (k-1); ++j)
			cur[((1<<j)&i) > 0][j] ^= ori[i];


	int cnt = 0;
	for(int i = 0; i < (k-1); ++i){
		if(cur[0][i] != vals[0][i] && cur[1][i] != vals[1][i]){
			return ori;
		}
		if(cur[0][i] != vals[0][i] || cur[1][i] != vals[1][i])
			++cnt;
	}
	if(cnt == 0)
		return ori;
	if(cnt != k-1)
		return ori;
	
	int falidx = 0;
	for(int i = 0; i < (k-1); ++i)
		if(cur[1][i] != vals[1][i])
			falidx += (1<<i);
	
	ori[falidx] ^= 1;
	return ori;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 4 ms 612 KB WA in grader: wrong source retrieval
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 972 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -