Submission #599771

#TimeUsernameProblemLanguageResultExecution timeMemory
599771MounirFlight to the Ford (BOI22_communication)C++17
Compilation error
0 ms0 KiB
#include "communication.h" #include <bits/stdc++.h> #define all(v) v.begin(), v.end() #define chmax(x, v) x = max(x, v) #define chmin(x, v) x = min(x, v) #define pb push_back #define pii pair<int, int> #define sz(x) (int)x.size() #define x first #define y second #define int long long using namespace std; void encode(int N, int X){ if (X == 1){ for (int i = 0; i < 6; ++i) int ans = send(i%2); } else if (X == 2){ for (int i = 0; i < 6; ++i) int ans = send(1 - i%2); } else { for (int i = 0; i < 6; ++i) int ans = send(i%3 == 0); } } vector<int> un = {0, 1, 0, 1, 0, 1}, deux = {1, 0, 1, 0, 1, 0}, trois = {1, 0, 0, 1, 0, 0}; pii decode(int N){ vector<int> vals; for (int i = 0; i < 6; ++i) vals.pb(receive()); for (int mask = 0; mask < (1 << 6); ++mask){ bool valid = true; vector<int> inds; for (int i = 0; i < 6; ++i){ if ((mask&(1 << i)) > 0) inds.pb(i); } for (int i = 0; i < sz(inds) - 1; ++i) valid &= (inds[i] != inds[i + 1] - 1); if (!valid) continue; vector<int> change = vals; for (int ind : inds) change[ind] ^= 1; if (change == un) return {1, 1}; if (change == deux) return {2, 2}; if (change == trois) return {3, 3}; } }

Compilation message (stderr)

communication.cpp: In function 'void encode(long long int, long long int)':
communication.cpp:17:23: warning: unused variable 'ans' [-Wunused-variable]
   17 |                   int ans = send(i%2);
      |                       ^~~
communication.cpp:21:23: warning: unused variable 'ans' [-Wunused-variable]
   21 |                   int ans = send(1 - i%2);
      |                       ^~~
communication.cpp:25:23: warning: unused variable 'ans' [-Wunused-variable]
   25 |                   int ans = send(i%3 == 0);
      |                       ^~~
communication.cpp: In function 'std::pair<long long int, long long int> decode(long long int)':
communication.cpp:32:19: warning: control reaches end of non-void function [-Wreturn-type]
   32 |       vector<int> vals;
      |                   ^~~~
/usr/bin/ld: /tmp/cci2B14E.o: in function `_do_encode(int, int)':
interface.cpp:(.text+0x1d9): undefined reference to `encode(int, int)'
/usr/bin/ld: /tmp/cci2B14E.o: in function `_do_decode(int)':
interface.cpp:(.text+0x219): undefined reference to `decode(int)'
/usr/bin/ld: /tmp/cci2B14E.o: in function `main':
interface.cpp:(.text.startup+0xac): undefined reference to `decode(int)'
/usr/bin/ld: interface.cpp:(.text.startup+0x15c): undefined reference to `encode(int, int)'
collect2: error: ld returned 1 exit status