답안 #748051

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
748051 2023-05-25T10:39:30 Z vjudge1 Data Transfer (IOI19_transfer) C++17
100 / 100
1423 ms 2500 KB
#include "transfer.h"

#include <bits/stdc++.h>

using namespace std;

vector<int> get_attachment(vector<int> source) {
	vector<int> res;
	int K = (source.size()<100?6:8);
	int safe = 0;
	for (int i = 0; i < K; i++) {
		int x = 0;
		int block = 1 << i;
		for (int j = 0; j < source.size(); j++) {
			if ((j / block) % 2 == 0) {
				x ^= source[j];
			}
		}
		res.push_back(x);
		safe ^= x;
	}
	res.push_back(safe);
	return res;
}

vector<int> retrieve(vector<int> data) {
	int n;
	if (data.size() < 100) {
		n = 63;
	} else {
		n = 255;
	}
	int safe = data.back();
	vector<int> source = vector<int>(data.begin(), data.begin()+n);
	vector<int> cnt(n);
	vector<int> v = vector<int>(data.begin()+n, data.end()-1);
	int K = (source.size()<100?6:8);
	int p = 0;
	for (int i : v) p ^= i;
	if (p != safe) return source;
	for (int i = 0; i < K; i++) {
		int x = 0;
		int block = 1 << i;
		for (int j = 0; j < n; j++) {
			if ((j / block) % 2 == 0) {
				x ^= source[j];
			}
		}
		for (int j = 0; j < n; j++) {
			if ((j / block) % 2 == (x == v[i])) {
				cnt[j]++;
			}
		}
	}
	for (int i = 0; i < n; i++) {
		if (cnt[i] == K) {
			source[i] ^= 1;
			return source;
		}
	}
	return source;
}

Compilation message

transfer.cpp: In function 'std::vector<int> get_attachment(std::vector<int>)':
transfer.cpp:14:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   14 |   for (int j = 0; j < source.size(); j++) {
      |                   ~~^~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 19 ms 704 KB Output is correct
2 Correct 19 ms 648 KB Output is correct
3 Correct 19 ms 740 KB Output is correct
4 Correct 19 ms 640 KB Output is correct
5 Correct 18 ms 644 KB Output is correct
6 Correct 20 ms 656 KB Output is correct
7 Correct 19 ms 652 KB Output is correct
8 Correct 20 ms 720 KB Output is correct
9 Correct 19 ms 676 KB Output is correct
10 Correct 21 ms 652 KB Output is correct
11 Correct 19 ms 732 KB Output is correct
12 Correct 18 ms 728 KB Output is correct
13 Correct 18 ms 704 KB Output is correct
14 Correct 19 ms 728 KB Output is correct
15 Correct 19 ms 652 KB Output is correct
16 Correct 19 ms 652 KB Output is correct
17 Correct 21 ms 700 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1378 ms 2496 KB Output is correct
2 Correct 1382 ms 2484 KB Output is correct
3 Correct 1404 ms 2452 KB Output is correct
4 Correct 1392 ms 2496 KB Output is correct
5 Correct 1412 ms 2496 KB Output is correct
6 Correct 1411 ms 2500 KB Output is correct
7 Correct 1414 ms 2488 KB Output is correct
8 Correct 1395 ms 2484 KB Output is correct
9 Correct 1399 ms 2460 KB Output is correct
10 Correct 1390 ms 2496 KB Output is correct
11 Correct 1402 ms 2488 KB Output is correct
12 Correct 1423 ms 2488 KB Output is correct
13 Correct 1415 ms 2484 KB Output is correct
14 Correct 1393 ms 2484 KB Output is correct
15 Correct 1386 ms 2456 KB Output is correct
16 Correct 1400 ms 2468 KB Output is correct
17 Correct 1390 ms 2492 KB Output is correct
18 Correct 1399 ms 2488 KB Output is correct
19 Correct 1384 ms 2496 KB Output is correct