답안 #962611

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
962611 2024-04-14T02:40:16 Z biank Data Transfer (IOI19_transfer) C++14
100 / 100
51 ms 2624 KB
#include "transfer.h"

using namespace std;

#define sz(x) int(x.size())
#define all(x) begin(x), end(x)

vector<int> get_attachment(vector<int> source) {
	int x = 0;
    for (int i = 0; i < sz(source); i++) {
        if (source[i]) x ^= i + 1;
    }
    vector<int> code;
    int log = sz(source) == 63 ? 6 : 8;
    for (int i = 0; i < log; i++) {
        code.push_back(x >> i & 1);
    }
    code.push_back(__builtin_parity(x));
    return code;
}

vector<int> retrieve(vector<int> data) {
    int cut = sz(data) == 70 ? 63 : 255;
    vector<int> source(begin(data), begin(data) + cut);
    vector<int> code(begin(data) + cut, end(data));
    int x = 0;
    for (int i = 0; i < sz(code) - 1; i++) {
        if (code[i]) x |= 1 << i;
    }
    if (code.back() != __builtin_parity(x)) {
        return source;
    }
    for (int i = 0; i < sz(source); i++) {
        if (source[i]) x ^= i + 1;
    }
    if (x != 0) source[x - 1] ^= 1;
    return source;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 792 KB Output is correct
2 Correct 1 ms 788 KB Output is correct
3 Correct 2 ms 840 KB Output is correct
4 Correct 2 ms 956 KB Output is correct
5 Correct 3 ms 784 KB Output is correct
6 Correct 3 ms 796 KB Output is correct
7 Correct 2 ms 792 KB Output is correct
8 Correct 2 ms 792 KB Output is correct
9 Correct 2 ms 788 KB Output is correct
10 Correct 1 ms 800 KB Output is correct
11 Correct 3 ms 800 KB Output is correct
12 Correct 3 ms 1284 KB Output is correct
13 Correct 2 ms 784 KB Output is correct
14 Correct 2 ms 788 KB Output is correct
15 Correct 1 ms 1012 KB Output is correct
16 Correct 2 ms 792 KB Output is correct
17 Correct 1 ms 792 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 37 ms 2604 KB Output is correct
2 Correct 37 ms 2508 KB Output is correct
3 Correct 47 ms 2624 KB Output is correct
4 Correct 40 ms 2520 KB Output is correct
5 Correct 41 ms 2516 KB Output is correct
6 Correct 51 ms 2424 KB Output is correct
7 Correct 42 ms 2508 KB Output is correct
8 Correct 35 ms 2516 KB Output is correct
9 Correct 33 ms 2516 KB Output is correct
10 Correct 32 ms 2508 KB Output is correct
11 Correct 31 ms 2508 KB Output is correct
12 Correct 43 ms 2508 KB Output is correct
13 Correct 39 ms 2512 KB Output is correct
14 Correct 43 ms 2504 KB Output is correct
15 Correct 40 ms 2508 KB Output is correct
16 Correct 41 ms 2508 KB Output is correct
17 Correct 39 ms 2512 KB Output is correct
18 Correct 38 ms 2520 KB Output is correct
19 Correct 40 ms 2528 KB Output is correct