Submission #1074948

# Submission time Handle Problem Language Result Execution time Memory
1074948 2024-08-25T17:02:08 Z raduv Norela (info1cup18_norela) C++17
0 / 100
800 ms 344 KB
#include <bits/stdc++.h>
#define int long long
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, 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;
    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:11:13: warning: format '%d' expects argument of type 'int*', but argument 2 has type 'long long int*' [-Wformat=]
   11 |     scanf("%d%d", &n, &m);
      |            ~^     ~~
      |             |     |
      |             int*  long long int*
      |            %lld
norela.cpp:11:15: warning: format '%d' expects argument of type 'int*', but argument 3 has type 'long long int*' [-Wformat=]
   11 |     scanf("%d%d", &n, &m);
      |              ~^       ~~
      |               |       |
      |               int*    long long int*
      |              %lld
norela.cpp:13:15: warning: format '%d' expects argument of type 'int*', but argument 2 has type 'long long int*' [-Wformat=]
   13 |       scanf("%d", &q);
      |              ~^   ~~
      |               |   |
      |               |   long long int*
      |               int*
      |              %lld
norela.cpp:15:17: warning: format '%d' expects argument of type 'int*', but argument 2 has type 'long long int*' [-Wformat=]
   15 |         scanf("%d", &bit);
      |                ~^   ~~~~
      |                 |   |
      |                 |   long long int*
      |                 int*
      |                %lld
norela.cpp:34:14: warning: format '%d' expects argument of type 'int', but argument 2 has type 'long long int' [-Wformat=]
   34 |     printf("%d\n", mn);
      |             ~^     ~~
      |              |     |
      |              int   long long int
      |             %lld
norela.cpp:37:18: warning: format '%d' expects argument of type 'int', but argument 2 has type 'long long int' [-Wformat=]
   37 |         printf("%d ", i + 1);
      |                 ~^    ~~~~~
      |                  |      |
      |                  int    long long int
      |                 %lld
norela.cpp:9:26: warning: unused variable 'no' [-Wunused-variable]
    9 |     int n, m, q, bit, i, no, mn, mask, cmask;
      |                          ^~
norela.cpp:11:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   11 |     scanf("%d%d", &n, &m);
      |     ~~~~~^~~~~~~~~~~~~~~~
norela.cpp:13:12: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |       scanf("%d", &q);
      |       ~~~~~^~~~~~~~~~
norela.cpp:15:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   15 |         scanf("%d", &bit);
      |         ~~~~~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Execution timed out 1041 ms 344 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1041 ms 344 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1041 ms 344 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1041 ms 344 KB Time limit exceeded
2 Halted 0 ms 0 KB -