Submission #636256

#TimeUTC-0UsernameProblemLanguageResultExecution timeMemory
6362562022-08-28 15:54:02null_aweFlight to the Ford (BOI22_communication)C++17
90 / 100
2778 ms2092 KiB
#include <bits/stdc++.h>
#include <communication.h>
using namespace std;
inline void s(int& x, int b, int v) { x -= (x & (1 << b)), x |= v << b; }
void encode(int n, int x) {
set<int> todo; for (int i = 0; i < 30; ++i) todo.insert(i);
vector<pair<int, int>> same, diff;
int a = 0, b = 1, l = -1, last = -1;
while (todo.size() > 1) {
int b1 = *todo.begin(), b2 = *++todo.begin();
vector<int> res(4);
if (b1 == last) res[0] = l;
else res[0] = send((x >> b1) & 1);
res[1] = send((x >> b2) & 1);
res[2] = send((x >> b2) & 1);
if (res[1] == res[2]) {
a |= res[1] << b2, b |= res[1] << b2;
todo.erase(b2);
l = res[2], last = b2;
continue;
}
res[3] = send((x >> b1) & 1);
l = res[3], last = b1;
if (res[0] == res[3]) {
s(a, b1, res[0]), s(b, b1, res[0]), s(b, b2, 1);
int taken = 0;
for (int i = 0; i < same.size() - taken; ++i)
if (same[i].first == b1)
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Compilation message (stderr)

communication.cpp: In function 'void encode(int, int)':
communication.cpp:29:25: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   29 |       for (int i = 0; i < same.size() - taken; ++i)
      |                       ~~^~~~~~~~~~~~~~~~~~~~~
communication.cpp:38:25: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   38 |       for (int i = 0; i < diff.size() - taken; ++i)
      |                       ~~^~~~~~~~~~~~~~~~~~~~~
communication.cpp: In function 'std::pair<int, int> decode(int)':
communication.cpp:82:25: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   82 |       for (int i = 0; i < same.size() - taken; ++i)
      |                       ~~^~~~~~~~~~~~~~~~~~~~~
communication.cpp:91:25: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   91 |       for (int i = 0; i < diff.size() - taken; ++i)
      |                       ~~^~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...