func_code_string: #include <bits/stdc++.h>   using namespace std;   class TwoSAT {    private:     const static int maxm = 100010 * 2;     int S[maxm], c;     vector<int> G[maxm];     bool DFS(int u) {       if (vis[u ^ 1]) return false;       if (vis[u]) return true;       vis[u] = 1;       S[c++] = u;       for (auto &v : G[u])         if (!DFS(v)) return false;       return true;     }       public:     int N;     bool vis[maxm];     void Clear() {       for (int i = 2; i < (N + 1) * 2; ++i) G[i].clear();       memset(vis, 0, sizeof(bool) * (N + 1) * 2);     }     void AddClause(int x, int xv, int y, int yv) {       x = x * 2 + xv;       y = y * 2 + yv;       G[x].push_back(y);       G[y].push_back(x);     }     bool Solve() {       for (int i = 2; i < (N + 1) * 2; i += 2)         if (!vis[i] && !vis[i + 1]) {           c = 0;           if (!DFS(i)) {             while (c > 0) vis[S[--c]] = 0;             if (!DFS(i + 1)) return false;           }         }       return true;     }   };   int n, m;   bool r[100010];   int f[100010];   TwoSAT ts;   int main() {     ios::sync_with_stdio(false);     int i, j, x, y;     cin >> n >> m;     ts.N = m + 1;     for (i = 1; i <= n; ++i) cin >> r[i];     for (i = 1; i <= m; ++i) {       cin >> x;       for (j = 0; j < x; ++j) {         cin >> y;         if (f[y]) {           if (r[y]) {             ts.AddClause(f[y], 1, i, 1);             ts.AddClause(f[y], 0, i, 0);           } else {             ts.AddClause(f[y], 1, i, 0);             ts.AddClause(f[y], 0, i, 1);           }         } else           f[y] = i;       }     }     if (ts.Solve())       puts( YES );     else       puts( NO );     return 0;   }   