Submission #668193

# Submission time Handle Problem Language Result Execution time Memory
668193 2022-12-03T08:42:12 Z fatemetmhr Flight to the Ford (BOI22_communication) C++17
74 / 100
3316 ms 2092 KB
// Willkommen! hier ist der Ort, an dem du sterben wirst :)

#include"communication.h"
#include <bits/stdc++.h>

using namespace std;

typedef long long   ll;
typedef long double ld;

#define all(x) x.begin(), x.end()
#define pb     push_back
#define fi     first
#define se     second

const int maxn5 = 3e5 + 10;
const ll  inf   = 1e18;
const int lg    = 30;

void encode(int n, int x){
    int g = 0;
    for(int i = 1; i < lg; i++){
        int a1 = send((x >> g)&1);
        int b1 = send((x >> i)&1);
        int b2 = send((x >> i)&1);
        int a2 = send((x >> g)&1);
        if(b1 == b2)
            continue;
        if(a1 == a2)
            g = i;
    }
}

pair<int, int> decode(int N){
    int a = 0, b = 1, g = 0;
    for(int i = 1; i < lg; i++){
        int a1 = receive();
        int b1 = receive();
        int b2 = receive();
        int a2 = receive();
        if(b1 == b2){
            a ^= (b1 << i);
            b ^= (b1 << i);
            continue;
        }
        if(a1 == a2){
            if(((a >> g)&1) != a1)
                a = b;
            else
                b = a;
            a ^= (1 << i);
            g = i;
            continue;
        }
        if(((a >> g)&1) != a1)
            swap(a, b);
        a |= (b2 << i);
        b |= (b1 << i);
    }
    a = max(a, 1); a = min(a, N);
    b = max(b, 1); b = min(b, N);
    return {a, b};
}
# Verdict Execution time Memory Grader output
1 Correct 71 ms 1680 KB Output is correct
2 Correct 160 ms 1712 KB Output is correct
3 Correct 209 ms 1688 KB Output is correct
4 Correct 90 ms 1724 KB Output is correct
5 Correct 146 ms 1740 KB Output is correct
6 Correct 323 ms 1880 KB Output is correct
7 Correct 551 ms 1744 KB Output is correct
# Verdict Execution time Memory Grader output
1 Partially correct 869 ms 1720 KB Output is partially correct
2 Partially correct 438 ms 1768 KB Output is partially correct
3 Partially correct 440 ms 1732 KB Output is partially correct
4 Partially correct 954 ms 1840 KB Output is partially correct
5 Partially correct 630 ms 1664 KB Output is partially correct
6 Partially correct 654 ms 1664 KB Output is partially correct
7 Partially correct 2114 ms 1844 KB Output is partially correct
8 Partially correct 3284 ms 1868 KB Output is partially correct
9 Partially correct 3093 ms 1952 KB Output is partially correct
10 Partially correct 2908 ms 1928 KB Output is partially correct
11 Partially correct 2812 ms 1848 KB Output is partially correct
12 Partially correct 2895 ms 1876 KB Output is partially correct
13 Partially correct 2675 ms 1892 KB Output is partially correct
14 Partially correct 3080 ms 1836 KB Output is partially correct
15 Partially correct 1640 ms 1724 KB Output is partially correct
16 Partially correct 3316 ms 1724 KB Output is partially correct
17 Partially correct 752 ms 1772 KB Output is partially correct
18 Partially correct 825 ms 1808 KB Output is partially correct
19 Partially correct 942 ms 1804 KB Output is partially correct
20 Partially correct 928 ms 1780 KB Output is partially correct
21 Partially correct 882 ms 2092 KB Output is partially correct
22 Partially correct 892 ms 1724 KB Output is partially correct
23 Partially correct 1358 ms 1856 KB Output is partially correct
24 Correct 102 ms 1672 KB Output is correct
25 Correct 166 ms 1684 KB Output is correct
26 Correct 206 ms 1856 KB Output is correct
27 Correct 108 ms 1660 KB Output is correct
28 Correct 134 ms 1768 KB Output is correct
29 Correct 374 ms 1764 KB Output is correct
30 Correct 700 ms 1684 KB Output is correct