Submission #601108

#TimeUsernameProblemLanguageResultExecution timeMemory
601108alextodoranFlight to the Ford (BOI22_communication)C++17
0 / 100
42 ms1848 KiB
/** ____ ____ ____ ____ ____ ||a |||t |||o |||d |||o || ||__|||__|||__|||__|||__|| |/__\|/__\|/__\|/__\|/__\| **/ #include <bits/stdc++.h> #include "communication.h" using namespace std; typedef long long ll; const int SEED = 3000; const int W_MAX = 5; int send (int s); void encode (int N, int X) { mt19937 rnd(SEED); N--; X--; while (N > 0) { int w; int bit = X % 2; bool lied = false; int cnt = 0; while (true) { if (cnt % W_MAX == 0) { w = rnd() % (W_MAX - 1) + 1; } cnt++; int r[] = {(rnd() % W_MAX < w), (rnd() % W_MAX < 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; bool lied[] = {false, false}; int cnt = 0; while (true) { if (cnt % W_MAX == 0) { w = rnd() % (W_MAX - 1) + 1; } cnt++; int r[] = {(rnd() % W_MAX < w), (rnd() % W_MAX < 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:33:39: 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]
   33 |             int r[] = {(rnd() % W_MAX < w), (rnd() % W_MAX < w)};
      |                         ~~~~~~~~~~~~~~^~~
communication.cpp:33:60: 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]
   33 |             int r[] = {(rnd() % W_MAX < w), (rnd() % W_MAX < w)};
      |                                              ~~~~~~~~~~~~~~^~~
communication.cpp: In function 'std::pair<int, int> decode(int)':
communication.cpp:63:39: 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]
   63 |             int r[] = {(rnd() % W_MAX < w), (rnd() % W_MAX < w)};
      |                         ~~~~~~~~~~~~~~^~~
communication.cpp:63:60: 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]
   63 |             int r[] = {(rnd() % W_MAX < w), (rnd() % W_MAX < w)};
      |                                              ~~~~~~~~~~~~~~^~~
communication.cpp: In function 'void encode(int, int)':
communication.cpp:33:41: warning: 'w' may be used uninitialized in this function [-Wmaybe-uninitialized]
   33 |             int r[] = {(rnd() % W_MAX < w), (rnd() % W_MAX < w)};
      |                                         ^
communication.cpp: In function 'std::pair<int, int> decode(int)':
communication.cpp:63:41: warning: 'w' may be used uninitialized in this function [-Wmaybe-uninitialized]
   63 |             int r[] = {(rnd() % W_MAX < w), (rnd() % W_MAX < w)};
      |                                         ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...