Submission #920377

# Submission time Handle Problem Language Result Execution time Memory
920377 2024-02-02T13:55:28 Z Pannda Data Transfer (IOI19_transfer) C++14
0 / 100
1 ms 1112 KB
#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;
    }
    cout << "xor: " << xr << '\n';
    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);
        }
        cout << "corrupted index inferred: " << xr - 1 << '\n';
        if (xr > 0) {
            data[xr - 1] ^= 1;
        }
	}
    return vector<int>(data.begin(), data.end() - k - 1);
}
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 780 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 1112 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -