Submission #601105

# Submission time Handle Problem Language Result Execution time Memory
601105 2022-07-21T11:15:46 Z alextodoran Flight to the Ford (BOI22_communication) C++17
0 / 100
29 ms 1716 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 w = rnd() % 9 + 1;
        int bit = X % 2;
        bool lied = false;
        while (true) {
            int r[] = {(rnd() % 10 < w), (rnd() % 10 < w)};
            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) {
        int w = rnd() % 9 + 1;
        bool lied[] = {false, false};
        while (true) {
            int r[] = {(rnd() % 10 < w), (rnd() % 10 < w)};
            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);
}

Compilation message

communication.cpp: In function 'void encode(int, int)':
communication.cpp:27:36: warning: comparison of integer expressions of different signedness: 'std::mersenne_twister_engine<long unsigned int, 32, 624, 397, 31, 2567483615, 11, 4294967295, 7, 2636928640, 15, 4022730752, 18, 1812433253>::result_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   27 |             int r[] = {(rnd() % 10 < w), (rnd() % 10 < w)};
      |                         ~~~~~~~~~~~^~~
communication.cpp:27:54: warning: comparison of integer expressions of different signedness: 'std::mersenne_twister_engine<long unsigned int, 32, 624, 397, 31, 2567483615, 11, 4294967295, 7, 2636928640, 15, 4022730752, 18, 1812433253>::result_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   27 |             int r[] = {(rnd() % 10 < w), (rnd() % 10 < w)};
      |                                           ~~~~~~~~~~~^~~
communication.cpp: In function 'std::pair<int, int> decode(int)':
communication.cpp:52:36: warning: comparison of integer expressions of different signedness: 'std::mersenne_twister_engine<long unsigned int, 32, 624, 397, 31, 2567483615, 11, 4294967295, 7, 2636928640, 15, 4022730752, 18, 1812433253>::result_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   52 |             int r[] = {(rnd() % 10 < w), (rnd() % 10 < w)};
      |                         ~~~~~~~~~~~^~~
communication.cpp:52:54: warning: comparison of integer expressions of different signedness: 'std::mersenne_twister_engine<long unsigned int, 32, 624, 397, 31, 2567483615, 11, 4294967295, 7, 2636928640, 15, 4022730752, 18, 1812433253>::result_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   52 |             int r[] = {(rnd() % 10 < w), (rnd() % 10 < w)};
      |                                           ~~~~~~~~~~~^~~
# Verdict Execution time Memory Grader output
1 Correct 22 ms 1716 KB Output is correct
2 Correct 29 ms 1676 KB Output is correct
3 Incorrect 4 ms 200 KB Not correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 220 KB Not correct
2 Halted 0 ms 0 KB -