Submission #1074956

# Submission time Handle Problem Language Result Execution time Memory
1074956 2024-08-25T17:05:04 Z raduv Norela (info1cup18_norela) C++17
0 / 100
19 ms 348 KB
#include <bits/stdc++.h>
const int MAXM = 24;
const int MAXN = 60;
using namespace std;
long long v[MAXM];
signed main()
{
    int n, m, q, bit, i, no, mn;
    long long rez, mask, cmask;
    scanf("%d%d", &n, &m);
    for( i = 0; i < m; i++ ){
      scanf("%d", &q);
      while(q--){
        scanf("%d", &bit);
        bit--;
        v[i] |= (1 << bit);
      }
    }
    mn = m + 1;
    cmask = 0;
    for( mask = 0; mask < (1 << m); mask++ ){
      rez = 0;
      for( i = 0; i < m; i++ ){
        if(mask & (1 << i)){
          rez ^= v[i];
        }
      }
      if(__builtin_popcount(rez) == n && __builtin_popcount(mask) < mn){
        mn = __builtin_popcount(mask);
        cmask = mask;
      }
    }
    printf("%d\n", mn);
    for( i = 0; i < m; i++ ){
      if(cmask & (1 << i))
        printf("%d ", i + 1);
    }
    return 0;
}

Compilation message

norela.cpp: In function 'int main()':
norela.cpp:8:26: warning: unused variable 'no' [-Wunused-variable]
    8 |     int n, m, q, bit, i, no, mn;
      |                          ^~
norela.cpp:10:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   10 |     scanf("%d%d", &n, &m);
      |     ~~~~~^~~~~~~~~~~~~~~~
norela.cpp:12:12: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   12 |       scanf("%d", &q);
      |       ~~~~~^~~~~~~~~~
norela.cpp:14:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   14 |         scanf("%d", &bit);
      |         ~~~~~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 19 ms 348 KB Output is correct
2 Incorrect 17 ms 344 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 19 ms 348 KB Output is correct
2 Incorrect 17 ms 344 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 19 ms 348 KB Output is correct
2 Incorrect 17 ms 344 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 19 ms 348 KB Output is correct
2 Incorrect 17 ms 344 KB Output isn't correct
3 Halted 0 ms 0 KB -