Submission #1090239

# Submission time Handle Problem Language Result Execution time Memory
1090239 2024-09-18T05:39:16 Z Gourougourou Conspiracy (POI11_kon) C++17
Compilation error
0 ms 0 KB
#include <iostream>
#include <bits/stdc++.h>
 
using namespace std;
 
 
int countAttackGroups(int N, int M, vector<int> &A, vector<int> &B) {
for (int i = 0; i<M; ++i) {
   adj[A[i]-1][B[i]-1] = true;
   adj[B[i]-1][A[i]-1] = true;
}
int ans = 0;
// check each group that isnt empty or all the nodes
for (int i = 1; i < (1 << N)-1; ++i) {
   vector<int> in, out;
   for (int node = 0; node < N; ++node) {
       if (i & (1 << node)) in.push_back(node);
       else out.push_back(node);
   }
   bool ok = true;
   for (int node1: in) {
       for (int node2: in) {
           if (node1 != node2) ok &= adj[node1][node2];
       }
   }
   for (int node1 : out) {
       for (int node2 : out) {
           ok &= !adj[node1][node2];
       }
   }
   if (ok) ++ans;
}
return ans;


}
 
int main() {
   ios::sync_with_stdio(0); cin.tie(0);
   int N;
   cin >> N;
   vector<int> A,B;
   A.reserve((N*(N-1))/2);
   B.reserve((N*(N-1))/2);
   for (int i = 1; i<=N; ++i) {
       int sz,a; cin >> sz;
       while (sz--) {
           cin >> a;
           if (a > i) {
               A.push_back(a);
               B.push_back(i);
           }
       }
 
   }
   cout << countAttackGroups(N, A.size(), A, B);
}

Compilation message

kon.cpp: In function 'int countAttackGroups(int, int, std::vector<int>&, std::vector<int>&)':
kon.cpp:9:4: error: 'adj' was not declared in this scope
    9 |    adj[A[i]-1][B[i]-1] = true;
      |    ^~~
kon.cpp:23:38: error: 'adj' was not declared in this scope
   23 |            if (node1 != node2) ok &= adj[node1][node2];
      |                                      ^~~
kon.cpp:28:19: error: 'adj' was not declared in this scope
   28 |            ok &= !adj[node1][node2];
      |                   ^~~