Submission #1090241

# Submission time Handle Problem Language Result Execution time Memory
1090241 2024-09-18T05:40:30 Z Gourougourou Conspiracy (POI11_kon) C++17
10 / 100
3000 ms 127276 KB
#include <iostream>
#include <bits/stdc++.h>
 
using namespace std;
const int MAXN = 20;
 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);
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 352 KB Output is correct
2 Correct 0 ms 360 KB Output is correct
3 Correct 0 ms 360 KB Output is correct
4 Correct 0 ms 360 KB Output is correct
5 Correct 0 ms 360 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 3072 ms 360 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3046 ms 344 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3029 ms 344 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 3 ms 600 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 4 ms 1132 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 6 ms 1624 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 30 ms 8020 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 52 ms 13076 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 528 ms 127276 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -