Submission #1074981

# Submission time Handle Problem Language Result Execution time Memory
1074981 2024-08-25T17:17:51 Z raduv Norela (info1cup18_norela) C++17
0 / 100
17 ms 344 KB
#include <bits/stdc++.h>
const int MAXM = 24;
using namespace std;
long long v[MAXM];
int main()
{
    int n, m, q, bit, i, no, mn, mask, cmask;
    long long rez;
    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;
    for( mask = 0; mask < (1 << m); mask++ ){
      rez = no = 0;
      for( i = 0; i < m; i++ ){
        if(mask & (1 << i)){
          rez ^= v[i];
          no++;
        }
      }
      if(rez == (1 << n) - 1 && no < mn){
        mn = no;
        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:9:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    9 |     scanf("%d%d", &n, &m);
      |     ~~~~~^~~~~~~~~~~~~~~~
norela.cpp:11:12: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   11 |       scanf("%d", &q);
      |       ~~~~~^~~~~~~~~~
norela.cpp:13:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |         scanf("%d", &bit);
      |         ~~~~~^~~~~~~~~~~~
norela.cpp:34:16: warning: 'cmask' may be used uninitialized in this function [-Wmaybe-uninitialized]
   34 |       if(cmask & (1 << i))
      |          ~~~~~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 17 ms 344 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 17 ms 344 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 17 ms 344 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 17 ms 344 KB Output is correct
2 Incorrect 17 ms 344 KB Output isn't correct
3 Halted 0 ms 0 KB -