Submission #1297929

#TimeUsernameProblemLanguageResultExecution timeMemory
1297929gesp3011v2Message (IOI24_message)C++20
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>
using namespace std;
//#include "message.h"
#define rep(i, n) for(int i = 0, i##__n = (int)(n); i < i##__n; ++i)
#define F(i,l,r) for(int i=l,i_end=r;i<i_end;++i)
#define FR(i,l,r) for(int i=l,i_end=r;i>=i_end;--i)
#define pb push_back
#define sz(x) x.size()

void send_message(vector<bool> M, vector<bool> C) {
	vector<vector<bool>> A(max(16, (sz(M) + 15) / 16 + 2), vector<bool>(31, false));
	vector<int> nxt(31, 1);
	rep(b, 31) if(!C[b])
		while(C[(b + nxt[b]) % 31]) nxt[b]++;
	rep(b, 31) if(!C[b]) A[nxt[b] - 1][b] = true;
	int pos = 0;
	rep(i, sz(A)) rep(b, 31) if(!C[b] && nxt[b] <= i)
		A[i][b] = (pos < sz(M) ? M[pos] : (pos == sz(M) ? true : false)), pos++;
	rep(i, sz(A)) send_packet(A[i]);
}

vector<bool> receive_message(vector<vector<bool>> A) {
	vector<int> nxt(31, 0);
	rep(b, 31) rep(i, 16) if(A[i][b]) { nxt[b] = i + 1; break; }
	vector<bool> C(31, true);
	rep(b, 31) {
		int cnt = 0;
		vector<bool> mark(31, false);
		for(int v = (b + nxt[b]) % 31; !mark[v]; v = (v + nxt[v]) % 31) mark[v] = true, cnt++;
		if(cnt == 16) rep(v, 31) C[v] = !mark[v];
	}

	vector<bool> M;
	rep(i, sz(A)) rep(b, 31) if(!C[b] && nxt[b] <= i)
		M.pb(A[i][b]);

	while(!M.back()) M.pop_back();
	M.pop_back();

	return M;
}

Compilation message (stderr)

message.cpp: In function 'void send_message(std::vector<bool>, std::vector<bool>)':
message.cpp:11:35: error: no matching function for call to 'max(int, std::vector<bool>::size_type)'
   11 |         vector<vector<bool>> A(max(16, (sz(M) + 15) / 16 + 2), vector<bool>(31, false));
      |                                ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/13/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:51,
                 from message.cpp:1:
/usr/include/c++/13/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/13/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
message.cpp:11:35: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'std::vector<bool>::size_type' {aka 'long unsigned int'})
   11 |         vector<vector<bool>> A(max(16, (sz(M) + 15) / 16 + 2), vector<bool>(31, false));
      |                                ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/13/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/13/bits/stl_algobase.h:303:5: note:   template argument deduction/substitution failed:
message.cpp:11:35: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'std::vector<bool>::size_type' {aka 'long unsigned int'})
   11 |         vector<vector<bool>> A(max(16, (sz(M) + 15) / 16 + 2), vector<bool>(31, false));
      |                                ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/13/algorithm:61:
/usr/include/c++/13/bits/stl_algo.h:5795:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
 5795 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/13/bits/stl_algo.h:5795:5: note:   template argument deduction/substitution failed:
message.cpp:11:35: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   11 |         vector<vector<bool>> A(max(16, (sz(M) + 15) / 16 + 2), vector<bool>(31, false));
      |                                ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/13/bits/stl_algo.h:5805:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
 5805 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/13/bits/stl_algo.h:5805:5: note:   template argument deduction/substitution failed:
message.cpp:11:35: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   11 |         vector<vector<bool>> A(max(16, (sz(M) + 15) / 16 + 2), vector<bool>(31, false));
      |                                ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
message.cpp:19:23: error: 'send_packet' was not declared in this scope
   19 |         rep(i, sz(A)) send_packet(A[i]);
      |                       ^~~~~~~~~~~