Submission #601105

#TimeUsernameProblemLanguageResultExecution timeMemory
601105alextodoranFlight to the Ford (BOI22_communication)C++17
0 / 100
29 ms1716 KiB
/** ____ ____ ____ ____ ____ ||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 (stderr)

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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...