답안 #1090240

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1090240 2024-09-18T05:39:58 Z Gourougourou Conspiracy (POI11_kon) C++17
컴파일 오류
0 ms 0 KB
#include <iostream>
#include <bits/stdc++.h>
 
using namespace std;
 bool adj[MAXN][MAXN];


 
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:5:11: error: 'MAXN' was not declared in this scope
    5 |  bool adj[MAXN][MAXN];
      |           ^~~~
kon.cpp:5:17: error: 'MAXN' was not declared in this scope
    5 |  bool adj[MAXN][MAXN];
      |                 ^~~~
kon.cpp: In function 'int countAttackGroups(int, int, std::vector<int>&, std::vector<int>&)':
kon.cpp:11:4: error: 'adj' was not declared in this scope
   11 |    adj[A[i]-1][B[i]-1] = true;
      |    ^~~
kon.cpp:25:38: error: 'adj' was not declared in this scope
   25 |            if (node1 != node2) ok &= adj[node1][node2];
      |                                      ^~~
kon.cpp:30:19: error: 'adj' was not declared in this scope
   30 |            ok &= !adj[node1][node2];
      |                   ^~~