Submission #601092

# Submission time Handle Problem Language Result Execution time Memory
601092 2022-07-21T11:03:50 Z alextodoran Flight to the Ford (BOI22_communication) C++17
0 / 100
1279 ms 1872 KB
/**
 ____ ____ ____ ____ ____
||a |||t |||o |||d |||o ||
||__|||__|||__|||__|||__||
|/__\|/__\|/__\|/__\|/__\|

**/

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

using namespace std;

typedef long long ll;

const int SEED = 3000;

int send (int s);
void encode (int N, int X) {
    mt19937 rnd(SEED);
    N--; X--;
    while (N > 0) {
        int bit = X % 2;
        bool lied = false;
        while (true) {
            int r[] = {(rnd() % 2 == 0), (rnd() % 2 == 0)};
            if (send(r[bit]) != r[!bit]) {
                if (lied == true) {
                    break;
                }
                lied = true;
            } else {
                lied = false;
            }
        }
        N /= 2;
        X /= 2;
    }
}

int receive ();
pair <int, int> decode (int N) {
    mt19937 rnd(SEED);
    N--;
    int X = 0;
    int k = 0;
    while (N > 0) {
        bool lied[] = {false, false};
        while (true) {
            int r[] = {(rnd() % 2 == 0), (rnd() % 2 == 0)};
            int rec = receive();
            bool stop = false;
            for (int bit : {0, 1}) {
                if (rec != r[bit]) {
                    if (lied[bit] == true) {
                        X |= (!bit << k);
                        stop = true;
                        break;
                    }
                    lied[bit] = true;
                } else {
                    lied[bit] = false;
                }
            }
            if (stop == true) {
                break;
            }
        }
        N /= 2;
        k++;
    }
    X++;
    return make_pair(X, X);
}
# Verdict Execution time Memory Grader output
1 Correct 16 ms 1872 KB Output is correct
2 Correct 17 ms 1716 KB Output is correct
3 Correct 24 ms 1792 KB Output is correct
4 Correct 16 ms 1836 KB Output is correct
5 Correct 39 ms 1752 KB Output is correct
6 Incorrect 1 ms 292 KB Not correct
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Partially correct 1279 ms 1752 KB Output is partially correct
2 Partially correct 670 ms 1728 KB Output is partially correct
3 Partially correct 659 ms 1700 KB Output is partially correct
4 Incorrect 136 ms 288 KB Not correct
5 Halted 0 ms 0 KB -