Submission #601089

#TimeUsernameProblemLanguageResultExecution timeMemory
601089alextodoranFlight to the Ford (BOI22_communication)C++17
0 / 100
1 ms212 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 bit = X % 2; bool lied = false; cout << "send " << bit << "\n"; while (true) { int r[] = {rnd() & 1, rnd() & 1}; cout << r[0] << " " << r[1] << " => "; if (send(r[bit]) != r[!bit]) { if (lied == true) { cout << "finish\n"; 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) { cout << "find bit #" << k << "\n"; bool lied[] = {false, false}; while (true) { int r[] = {rnd() & 1, rnd() & 1}; cout << r[0] << " " << r[1] << " => "; int rec = receive(); bool stop = false; for (int bit : {0, 1}) { if (rec != r[bit]) { if (lied[bit] == true) { X |= (!bit << k); stop = true; cout << "found " << !bit << "\n"; 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: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()() & 1)' 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]
   27 |             int r[] = {rnd() & 1, rnd() & 1};
      |                        ~~~~~~^~~
communication.cpp:27: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()() & 1)' 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]
   27 |             int r[] = {rnd() & 1, rnd() & 1};
      |                                   ~~~~~~^~~
communication.cpp: In function 'std::pair<int, int> decode(int)':
communication.cpp:54: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()() & 1)' 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]
   54 |             int r[] = {rnd() & 1, rnd() & 1};
      |                        ~~~~~~^~~
communication.cpp:54: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()() & 1)' 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]
   54 |             int r[] = {rnd() & 1, rnd() & 1};
      |                                   ~~~~~~^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...