/**
* @the_hyp0cr1t3
* 20.01.2024 18:02
**/
#include <bits/stdc++.h>
std::vector<std::vector<int>> ops;
void recur(int l, int r, int d) {
if (r - l + 1 < 2) return;
if (ops.size() < d + 1)
ops.resize(d + 1);
int m = (l + r) / 2;
for (int i = l; i <= m; i++)
ops[d].push_back(i);
recur(l, m, d + 1);
recur(m + 1, r, d + 1);
}
int find(const std::string &s, int l, int r, int d) {
if (r - l + 1 < 2) {
assert(r - l + 1 == 1);
return l;
}
int m = (l + r) / 2;
if (s[d] == '1')
return find(s, l, m, d + 1);
else
return find(s, m + 1, r, d + 1);
}
int main() {
std::cin.tie(nullptr)->sync_with_stdio(false);
int n;
std::cin >> n;
recur(1, n, 0);
std::cout << ops.size() << std::endl;
for (const auto &v : ops) {
assert(!v.empty());
std::cout << v.size();
for (auto x : v)
std::cout << ' ' << x;
std::cout << std::endl;
}
std::string s;
std::cin >> s;
std::cout << find(s, 1, n, 0) << std::endl;
}
Main.cpp: In function ‘void recur(int, int, int)’:
Main.cpp:11:20: warning: comparison of integer expressions of different signedness: ‘std::vector<std::vector<int> >::size_type’ {aka ‘long unsigned int’} and ‘int’ [-Wsign-compare]
11 | if (ops.size() < d + 1)
| ~~~~~~~~~~~^~~~~~~