Submission #1062161

# Submission time Handle Problem Language Result Execution time Memory
1062161 2024-08-16T20:04:45 Z pera Norela (info1cup18_norela) C++17
100 / 100
358 ms 394440 KB
#include<bits/stdc++.h>
using namespace std;
main(){
   int n , m;
   cin >> n >> m;
   long long M = (1LL << n) - 1;
   vector<long long> v(m);
   for(int i = 0;i < m;i ++){
      int x;
      cin >> x;
      while(x--){
         int y;
         cin >> y;
         --y;
         v[i] |= (1LL << y);
      }
   }
   vector<pair<long long , int>> u;
   u.emplace_back(make_pair(0LL , 0));
   for(int i = 0;i < m;i ++){
      vector<pair<long long , int>> e;
      for(auto [x , mask] : u){
         e.emplace_back(make_pair(x ^ v[i] , mask | (1LL << i)));
      }
      for(auto [x , mask] : e){
         u.emplace_back(make_pair(x , mask));
      }
   }
   int best_mask = (1LL << (m + 1)) - 1;
   for(auto [x , mask] : u){
      if(x != M){
         continue;
      }
      if(__builtin_popcount(mask) < __builtin_popcount(best_mask)){
         best_mask = mask;
      }else if(__builtin_popcount(mask) == __builtin_popcount(best_mask)){
         int v = mask ^ best_mask;
         if(mask >> (__lg(v & -v)) & 1){
            best_mask = mask;
         }
      }
   }
   cout << __builtin_popcount(best_mask) << endl;
   for(int i = 0;i < m;i ++){
      if(best_mask >> i & 1){
         cout << i + 1 << " ";
      }
   }
   cout << endl;
}

Compilation message

norela.cpp:3:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    3 | main(){
      | ^~~~
# Verdict Execution time Memory Grader output
1 Correct 7 ms 7876 KB Output is correct
2 Correct 7 ms 8124 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 7 ms 7360 KB Output is correct
5 Correct 7 ms 8644 KB Output is correct
6 Correct 7 ms 7620 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 7876 KB Output is correct
2 Correct 7 ms 8124 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 7 ms 7360 KB Output is correct
5 Correct 7 ms 8644 KB Output is correct
6 Correct 7 ms 7620 KB Output is correct
7 Correct 21 ms 25568 KB Output is correct
8 Correct 41 ms 49956 KB Output is correct
9 Correct 40 ms 50984 KB Output is correct
10 Correct 41 ms 49960 KB Output is correct
11 Correct 40 ms 51472 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 7876 KB Output is correct
2 Correct 7 ms 8124 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 7 ms 7360 KB Output is correct
5 Correct 7 ms 8644 KB Output is correct
6 Correct 7 ms 7620 KB Output is correct
7 Correct 21 ms 25568 KB Output is correct
8 Correct 41 ms 49956 KB Output is correct
9 Correct 40 ms 50984 KB Output is correct
10 Correct 41 ms 49960 KB Output is correct
11 Correct 40 ms 51472 KB Output is correct
12 Correct 44 ms 49944 KB Output is correct
13 Correct 80 ms 100236 KB Output is correct
14 Correct 82 ms 99272 KB Output is correct
15 Correct 81 ms 99688 KB Output is correct
16 Correct 80 ms 99484 KB Output is correct
17 Correct 83 ms 99648 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 7876 KB Output is correct
2 Correct 7 ms 8124 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 7 ms 7360 KB Output is correct
5 Correct 7 ms 8644 KB Output is correct
6 Correct 7 ms 7620 KB Output is correct
7 Correct 21 ms 25568 KB Output is correct
8 Correct 41 ms 49956 KB Output is correct
9 Correct 40 ms 50984 KB Output is correct
10 Correct 41 ms 49960 KB Output is correct
11 Correct 40 ms 51472 KB Output is correct
12 Correct 44 ms 49944 KB Output is correct
13 Correct 80 ms 100236 KB Output is correct
14 Correct 82 ms 99272 KB Output is correct
15 Correct 81 ms 99688 KB Output is correct
16 Correct 80 ms 99484 KB Output is correct
17 Correct 83 ms 99648 KB Output is correct
18 Correct 158 ms 198824 KB Output is correct
19 Correct 150 ms 199064 KB Output is correct
20 Correct 342 ms 394436 KB Output is correct
21 Correct 342 ms 394424 KB Output is correct
22 Correct 357 ms 394436 KB Output is correct
23 Correct 358 ms 394440 KB Output is correct