답안 #1062159

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1062159 2024-08-16T20:04:04 Z pera Norela (info1cup18_norela) C++17
100 / 100
470 ms 394516 KB
#include<bits/stdc++.h>
#define int long long
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;
      }
      int o = best_mask ^ mask;
      if(__builtin_popcountll(mask) < __builtin_popcountll(best_mask)){
         best_mask = mask;
      }else if(__builtin_popcountll(mask) == __builtin_popcountll(best_mask)){
         int v = mask ^ best_mask;
         if(mask >> (__lg(v & -v)) & 1){
            best_mask = mask;
         }
      }
   }
   cout << __builtin_popcountll(best_mask) << endl;
   for(int i = 0;i < m;i ++){
      if(best_mask >> i & 1){
         cout << i + 1 << " ";
      }
   }
   cout << endl;
}

Compilation message

norela.cpp:4:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    4 | main(){
      | ^~~~
norela.cpp: In function 'int main()':
norela.cpp:35:11: warning: unused variable 'o' [-Wunused-variable]
   35 |       int o = best_mask ^ mask;
      |           ^
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 7876 KB Output is correct
2 Correct 9 ms 7868 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 8 ms 6852 KB Output is correct
5 Correct 8 ms 6736 KB Output is correct
6 Correct 8 ms 6596 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 7876 KB Output is correct
2 Correct 9 ms 7868 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 8 ms 6852 KB Output is correct
5 Correct 8 ms 6736 KB Output is correct
6 Correct 8 ms 6596 KB Output is correct
7 Correct 28 ms 26084 KB Output is correct
8 Correct 55 ms 51156 KB Output is correct
9 Correct 55 ms 50708 KB Output is correct
10 Correct 54 ms 49732 KB Output is correct
11 Correct 55 ms 50684 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 7876 KB Output is correct
2 Correct 9 ms 7868 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 8 ms 6852 KB Output is correct
5 Correct 8 ms 6736 KB Output is correct
6 Correct 8 ms 6596 KB Output is correct
7 Correct 28 ms 26084 KB Output is correct
8 Correct 55 ms 51156 KB Output is correct
9 Correct 55 ms 50708 KB Output is correct
10 Correct 54 ms 49732 KB Output is correct
11 Correct 55 ms 50684 KB Output is correct
12 Correct 53 ms 50424 KB Output is correct
13 Correct 100 ms 100932 KB Output is correct
14 Correct 100 ms 99656 KB Output is correct
15 Correct 103 ms 99116 KB Output is correct
16 Correct 99 ms 99920 KB Output is correct
17 Correct 100 ms 100820 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 7876 KB Output is correct
2 Correct 9 ms 7868 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 8 ms 6852 KB Output is correct
5 Correct 8 ms 6736 KB Output is correct
6 Correct 8 ms 6596 KB Output is correct
7 Correct 28 ms 26084 KB Output is correct
8 Correct 55 ms 51156 KB Output is correct
9 Correct 55 ms 50708 KB Output is correct
10 Correct 54 ms 49732 KB Output is correct
11 Correct 55 ms 50684 KB Output is correct
12 Correct 53 ms 50424 KB Output is correct
13 Correct 100 ms 100932 KB Output is correct
14 Correct 100 ms 99656 KB Output is correct
15 Correct 103 ms 99116 KB Output is correct
16 Correct 99 ms 99920 KB Output is correct
17 Correct 100 ms 100820 KB Output is correct
18 Correct 203 ms 197996 KB Output is correct
19 Correct 194 ms 197456 KB Output is correct
20 Correct 422 ms 394400 KB Output is correct
21 Correct 423 ms 394516 KB Output is correct
22 Correct 434 ms 394360 KB Output is correct
23 Correct 470 ms 394356 KB Output is correct