답안 #924356

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
924356 2024-02-08T21:55:28 Z AndrijaM Data Transfer (IOI19_transfer) C++14
100 / 100
36 ms 2760 KB
#include "transfer.h"
 
#include <bits/stdc++.h>
using namespace std;
 
std::vector<int> get_attachment(std::vector<int> source) {
    int n = source.size();
    int xr = 0;
    for (int i = 0; i < n; i++) {
        xr ^= source[i] * (i + 1);
    }
    int k = n == 63 ? 6 : 8;
    vector<int> attachment(k + 1);
    for (int i = 0; i < k; i++) {
        attachment[i] = xr >> i & 1;
    }
    attachment[k] = __builtin_popcount(xr) & 1;
    return attachment;
}
 
std::vector<int> retrieve(std::vector<int> data) {
	int n = data.size();
	int k = n == 63 + 7 ? 6 : 8;
	n -= k + 1;
	int parity = 0;
	for (int i = n; i < n + k + 1; i++) {
        parity = (parity + data[i]) & 1;
	}
	if (!(parity & 1)) {
        int xr = 0;
        for (int i = n; i < n + k; i++) {
            xr += data[i] << (i - n);
        }
        for (int i = 0; i < n; i++) {
            xr ^= data[i] * (i + 1);
        }
        if (xr > 0) {
            data[xr - 1] ^= 1;
        }
	}
    return vector<int>(data.begin(), data.end() - k - 1);
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 792 KB Output is correct
2 Correct 2 ms 792 KB Output is correct
3 Correct 1 ms 792 KB Output is correct
4 Correct 2 ms 792 KB Output is correct
5 Correct 1 ms 792 KB Output is correct
6 Correct 1 ms 792 KB Output is correct
7 Correct 1 ms 800 KB Output is correct
8 Correct 1 ms 792 KB Output is correct
9 Correct 2 ms 792 KB Output is correct
10 Correct 1 ms 792 KB Output is correct
11 Correct 2 ms 784 KB Output is correct
12 Correct 1 ms 784 KB Output is correct
13 Correct 2 ms 892 KB Output is correct
14 Correct 1 ms 800 KB Output is correct
15 Correct 1 ms 1100 KB Output is correct
16 Correct 1 ms 792 KB Output is correct
17 Correct 1 ms 796 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 26 ms 2516 KB Output is correct
2 Correct 30 ms 2516 KB Output is correct
3 Correct 36 ms 2520 KB Output is correct
4 Correct 27 ms 2508 KB Output is correct
5 Correct 28 ms 2508 KB Output is correct
6 Correct 27 ms 2516 KB Output is correct
7 Correct 27 ms 2516 KB Output is correct
8 Correct 27 ms 2512 KB Output is correct
9 Correct 27 ms 2504 KB Output is correct
10 Correct 27 ms 2512 KB Output is correct
11 Correct 27 ms 2760 KB Output is correct
12 Correct 27 ms 2516 KB Output is correct
13 Correct 27 ms 2512 KB Output is correct
14 Correct 27 ms 2508 KB Output is correct
15 Correct 27 ms 2564 KB Output is correct
16 Correct 27 ms 2516 KB Output is correct
17 Correct 27 ms 2508 KB Output is correct
18 Correct 27 ms 2516 KB Output is correct
19 Correct 28 ms 2512 KB Output is correct