Submission #467531

# Submission time Handle Problem Language Result Execution time Memory
467531 2021-08-23T12:44:43 Z LucaIlie Norela (info1cup18_norela) C
0 / 100
17 ms 276 KB
#include <stdio.h>

#define MAX_M 24

long long spell[MAX_M];



int main() {
    int n, m, k, p, minUsedSpells, usedSpells, solMask, mask, i, j;
    long long xor;

    scanf( "%d%d", &n, &m );
    for ( i = 0; i < m; i++ ) {
        scanf( "%d", &k );
        spell[i] = 0;
        for ( j = 0; j < k; j++ ) {
            scanf( "%d", &p );
            spell[i] += ((long long)1 << (p - 1));
        }
    }

    minUsedSpells = m + 1;
    solMask = -1;
    for ( mask = 0; mask < (1 << m); mask++ ) {
        xor = 0;
        usedSpells = 0;
        for ( i = 0; i < m; i++ ) {
            if ( ((mask >> i) & 1) == 1 ) {
                xor ^= spell[i];
                usedSpells++;
            }
        }
        if ( xor == ((long long)1 << n) - 1 ) {
            if ( usedSpells < minUsedSpells ) {
                minUsedSpells = usedSpells;
                solMask = mask;
            }
        }
    }

    printf( "%d\n", minUsedSpells );
    for ( i = 0; i < m; i++ ) {
        if ( ((solMask >> i) & 1) == 1 )
            printf( "%d ", i + 1 );
    }

    return 0;
}

Compilation message

norela.c: In function 'main':
norela.c:13:5: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |     scanf( "%d%d", &n, &m );
      |     ^~~~~~~~~~~~~~~~~~~~~~~
norela.c:15:9: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   15 |         scanf( "%d", &k );
      |         ^~~~~~~~~~~~~~~~~
norela.c:18:13: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   18 |             scanf( "%d", &p );
      |             ^~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 16 ms 204 KB Output is correct
2 Correct 17 ms 268 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 17 ms 204 KB Output is correct
5 Correct 17 ms 204 KB Output is correct
6 Incorrect 17 ms 276 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Correct 16 ms 204 KB Output is correct
2 Correct 17 ms 268 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 17 ms 204 KB Output is correct
5 Correct 17 ms 204 KB Output is correct
6 Incorrect 17 ms 276 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Correct 16 ms 204 KB Output is correct
2 Correct 17 ms 268 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 17 ms 204 KB Output is correct
5 Correct 17 ms 204 KB Output is correct
6 Incorrect 17 ms 276 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Correct 16 ms 204 KB Output is correct
2 Correct 17 ms 268 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 17 ms 204 KB Output is correct
5 Correct 17 ms 204 KB Output is correct
6 Incorrect 17 ms 276 KB Output isn't correct