Language: C++

#include<iostream>
#include <algorithm>
#include <set>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <string>
using namespace std;
typedef long long ll;
const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const int MOD = 1000000007;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//forとか代入しない場合は++iでもi++でも同じ


int main() {
  int N,M;
  cin >> N >> M;
  vector<int> K(M),P(M);
  vector<set<int>> S(M);
  for (int i = 0; i < M; i++)
  { 
      cin >> K[i];
      for (int j = 0; j < K[i]; j++)
      {
          int s;
          cin >> s;
          S[j].insert(s);
      }      
  }

  for (int i = 0; i < M; i++)
  {
      cin >> P[i];
  }
  
  int count = 0;
  for (int bit = 0; bit < 1<<N; bit++)
  {
      for (int i = 0; i < N; i++)
      {
         set<int> on_switch;
         if(bit&(1<<i)){
            on_switch.insert(bit&(1<<i));
         }
         
         bool ok = true;
         for (int j = 0; j < M; j++)
         {
             set<int> intersectSet;
             //今onにしているところと条件でonにしたい部分の積集合
             set_intersection(on_switch.begin(),on_switch.end(),S[j].begin(),S[j].end(),back_inserter(intersectSet));

             if(intersectSet.size()%2 != P[j] ){
                 //点灯していないとき
                 ok = false;
             }
         }

         if(ok){
             count++;
         }
         
      }
      
  }

  cout << count <<endl;

}




Compiler output:
In file included from /usr/include/c++/14/string:48,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_iterator.h: In instantiation of 'std::back_insert_iterator<_Container>& std::back_insert_iterator<_Container>::operator=(const typename _Container::value_type&) [with _Container = std::set<int>; typename _Container::value_type = int]':
/usr/include/c++/14/bits/stl_algo.h:5184:16:   required from '_OutputIterator std::__set_intersection(_InputIterator1, _InputIterator1, _InputIterator2, _InputIterator2, _OutputIterator, _Compare) [with _InputIterator1 = _Rb_tree_const_iterator<int>; _InputIterator2 = _Rb_tree_const_iterator<int>; _OutputIterator = back_insert_iterator<set<int> >; _Compare = __gnu_cxx::__ops::_Iter_less_iter]'
 5184 |             *__result = *__first1;
      |             ~~~~~~~~~~^~~~~~~~~~~
/usr/include/c++/14/bits/stl_algo.h:5234:48:   required from '_OIter std::set_intersection(_IIter1, _IIter1, _IIter2, _IIter2, _OIter) [with _IIter1 = _Rb_tree_const_iterator<int>; _IIter2 = _Rb_tree_const_iterator<int>; _OIter = back_insert_iterator<set<int> >]'
 5234 |       return _GLIBCXX_STD_A::__set_intersection(__first1, __last1,
      |                                                ^
a.cc:55:30:   required from here
   55 |              set_intersection(on_switch.begin(),on_switch.end(),S[j].begin(),S[j].end(),back_inserter(intersectSet));
      |              ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:730:20: error: 'class std::set<int>' has no member named 'push_back'
  730 |         container->push_back(__value);
      |         ~~~~~~~~~~~^~~~~~~~~