Language: C++

#include <bits/stdc++.h>

using i64 = int64_t;
template <class T> using Vec = std::vector<T>;

using namespace std;


int main() {
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(nullptr);

    int n, k, s, t;
    cin >> n >> k >> s >> t;

    Vec<int> as(n);
    for (auto &a : as) cin >> a;

    if ((s & t) != s || (s | t) != t) {
        cout << 0;
        return 0;
    }

    auto invalid = [&](int a) {
        return s != (s & a) || t != (t | a);
    };
    as.erase(remove_if(as.begin(), as.end(), invalid), as.end());

    n = as.size();

    Vec<map<int, map<int, i64>>> by_andor(k + 19);
    by_andor[0][t][s] = 1;

    for (int i = 0; i < as.size(); ++i) {
        int a = as[i];

        for (int j = min(i, k - 1); j >= 0; --j) {
            auto &next = by_andor[j + 1];

            for (auto &[aand, vvalue] : by_andor[j]) for (auto &[oor, value] : vvalue){
                next[aand & a][oor | a] += value;
            }
        }
    }

    i64 ans = 0;
    for (int i = 0; i <= k; ++i) ans += by_andor[i][{s, t}];
    cout << ans << '\n';

    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:47:52: error: no match for 'operator[]' (operand types are '__gnu_cxx::__alloc_traits<std::allocator<std::map<int, std::map<int, long int> > >, std::map<int, std::map<int, long int> > >::value_type' {aka 'std::map<int, std::map<int, long int> >'} and '<brace-enclosed initializer list>')
   47 |     for (int i = 0; i <= k; ++i) ans += by_andor[i][{s, t}];
      |                                                    ^
In file included from /usr/include/c++/14/map:63,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:152,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_map.h:504:7: note: candidate: 'std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type& std::map<_Key, _Tp, _Compare, _Alloc>::operator[](const key_type&) [with _Key = int; _Tp = std::map<int, long int>; _Compare = std::less<int>; _Alloc = std::allocator<std::pair<const int, std::map<int, long int> > >; mapped_type = std::map<int, long int>; key_type = int]'
  504 |       operator[](const key_type& __k)
      |       ^~~~~~~~
/usr/include/c++/14/bits/stl_map.h:504:34: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const std::map<int, std::map<int, long int> >::key_type&' {aka 'const int&'}
  504 |       operator[](const key_type& __k)
      |                  ~~~~~~~~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_map.h:524:7: note: candidate: 'std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type& std::map<_Key, _Tp, _Compare, _Alloc>::operator[](key_type&&) [with _Key = int; _Tp = std::map<int, long int>; _Compare = std::less<int>; _Alloc = std::allocator<std::pair<const int, std::map<int, long int> > >; mapped_type = std::map<int, long int>; key_type = int]'
  524 |       operator[](key_type&& __k)
      |       ^~~~~~~~
/usr/include/c++/14/bits/stl_map.h:524:29: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::map<int, std::map<int, long int> >::key_type&&' {aka 'int&&'}
  524 |       operator[](key_type&& __k)
      |                  ~~~~~~~~~~~^~~