Submission #742845

# Submission time Handle Problem Language Result Execution time Memory
742845 2023-05-17T03:56:26 Z nguyentunglam Data Transfer (IOI19_transfer) C++17
100 / 100
513 ms 2516 KB
#include "transfer.h"
#include<bits/stdc++.h>
using namespace std;

void up(int &pos) {
    pos++;
    while (__builtin_popcount(pos) == 1) pos++;
}

std::vector<int> get_attachment(std::vector<int> source) {
    int T = source.size() <= 63 ? 7 : 9;
    vector<int> ret(T);
    int pos = 0, timer = 0;
    for(int &val : source) {
        up(pos);
        for(int j = 0; j < T; j++) if (pos >> j & 1)  ret[j] ^= val;
    }
//    for(int &j : ret) cout << j; cout << endl;
    return ret;
}

std::vector<int> retrieve(std::vector<int> data) {
    int T = data.size() - 7 <= 63 ? 7 : 9;
    int n = data.size() - T;
    vector<int> ret;
    int pos = 0;
    for(int i = 0; i < n; i++) {
        up(pos);
        for(int j = 0; j < T; j++) if (pos >> j & 1) data[j + n] ^= data[i];
    }
    int wrong = 0;
    pos = 0;
    for(int j = 0; j < T; j++) if (data[j + n]) wrong |= (1 << j);
    for(int i = 0; i < n; i++) {
        up(pos);
        if (pos == wrong) data[i] ^= 1;
        ret.push_back(data[i]);
    }
    return ret;
}

Compilation message

transfer.cpp: In function 'std::vector<int> get_attachment(std::vector<int>)':
transfer.cpp:13:18: warning: unused variable 'timer' [-Wunused-variable]
   13 |     int pos = 0, timer = 0;
      |                  ^~~~~
# Verdict Execution time Memory Grader output
1 Correct 8 ms 640 KB Output is correct
2 Correct 8 ms 736 KB Output is correct
3 Correct 9 ms 816 KB Output is correct
4 Correct 9 ms 704 KB Output is correct
5 Correct 9 ms 644 KB Output is correct
6 Correct 9 ms 724 KB Output is correct
7 Correct 11 ms 728 KB Output is correct
8 Correct 9 ms 728 KB Output is correct
9 Correct 8 ms 652 KB Output is correct
10 Correct 8 ms 652 KB Output is correct
11 Correct 8 ms 644 KB Output is correct
12 Correct 8 ms 652 KB Output is correct
13 Correct 8 ms 644 KB Output is correct
14 Correct 8 ms 728 KB Output is correct
15 Correct 8 ms 644 KB Output is correct
16 Correct 8 ms 808 KB Output is correct
17 Correct 8 ms 732 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 501 ms 2480 KB Output is correct
2 Correct 470 ms 2456 KB Output is correct
3 Correct 479 ms 2496 KB Output is correct
4 Correct 506 ms 2488 KB Output is correct
5 Correct 474 ms 2496 KB Output is correct
6 Correct 485 ms 2500 KB Output is correct
7 Correct 468 ms 2484 KB Output is correct
8 Correct 499 ms 2516 KB Output is correct
9 Correct 460 ms 2488 KB Output is correct
10 Correct 505 ms 2496 KB Output is correct
11 Correct 505 ms 2496 KB Output is correct
12 Correct 513 ms 2488 KB Output is correct
13 Correct 480 ms 2412 KB Output is correct
14 Correct 486 ms 2488 KB Output is correct
15 Correct 497 ms 2492 KB Output is correct
16 Correct 496 ms 2496 KB Output is correct
17 Correct 493 ms 2488 KB Output is correct
18 Correct 482 ms 2488 KB Output is correct
19 Correct 499 ms 2488 KB Output is correct