Submission #601066

# Submission time Handle Problem Language Result Execution time Memory
601066 2022-07-21T10:52:02 Z alextodoran Flight to the Ford (BOI22_communication) C++17
0 / 100
107 ms 1888 KB
/**
 ____ ____ ____ ____ ____
||a |||t |||o |||d |||o ||
||__|||__|||__|||__|||__||
|/__\|/__\|/__\|/__\|/__\|

**/

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

using namespace std;

typedef long long ll;

int send (int s);
void encode (int N, int X) {
    mt19937 rnd(2400);
    while (N > 0) {
        int bit = X % 2;
        bool lied = false;
        while (true) {
            int r[] = {rnd() % 2, rnd() % 2};
            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) {
    int X = 0;
    mt19937 rnd(2400);
    int k = 0;
    while (N > 0) {
        bool lied[] = {false, false};
        while (true) {
            int r[] = {rnd() % 2, rnd() % 2};
            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++;
    }
    return make_pair(X, X);
}

Compilation message

communication.cpp: In function 'void encode(int, int)':
communication.cpp:23:30: warning: narrowing conversion of '(rnd.std::mersenne_twister_engine<long unsigned int, 32, 624, 397, 31, 2567483615, 11, 4294967295, 7, 2636928640, 15, 4022730752, 18, 1812433253>::operator()() % 2)' from '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'} to 'int' [-Wnarrowing]
   23 |             int r[] = {rnd() % 2, rnd() % 2};
      |                        ~~~~~~^~~
communication.cpp:23:41: warning: narrowing conversion of '(rnd.std::mersenne_twister_engine<long unsigned int, 32, 624, 397, 31, 2567483615, 11, 4294967295, 7, 2636928640, 15, 4022730752, 18, 1812433253>::operator()() % 2)' from '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'} to 'int' [-Wnarrowing]
   23 |             int r[] = {rnd() % 2, rnd() % 2};
      |                                   ~~~~~~^~~
communication.cpp: In function 'std::pair<int, int> decode(int)':
communication.cpp:46:30: warning: narrowing conversion of '(rnd.std::mersenne_twister_engine<long unsigned int, 32, 624, 397, 31, 2567483615, 11, 4294967295, 7, 2636928640, 15, 4022730752, 18, 1812433253>::operator()() % 2)' from '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'} to 'int' [-Wnarrowing]
   46 |             int r[] = {rnd() % 2, rnd() % 2};
      |                        ~~~~~~^~~
communication.cpp:46:41: warning: narrowing conversion of '(rnd.std::mersenne_twister_engine<long unsigned int, 32, 624, 397, 31, 2567483615, 11, 4294967295, 7, 2636928640, 15, 4022730752, 18, 1812433253>::operator()() % 2)' from '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'} to 'int' [-Wnarrowing]
   46 |             int r[] = {rnd() % 2, rnd() % 2};
      |                                   ~~~~~~^~~
# Verdict Execution time Memory Grader output
1 Correct 13 ms 1848 KB Output is correct
2 Correct 28 ms 1808 KB Output is correct
3 Correct 19 ms 1832 KB Output is correct
4 Correct 10 ms 1704 KB Output is correct
5 Correct 93 ms 1888 KB Output is correct
6 Incorrect 2 ms 292 KB Not correct
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 107 ms 200 KB Not correct
2 Halted 0 ms 0 KB -