Submission #467525

# Submission time Handle Problem Language Result Execution time Memory
467525 2021-08-23T12:27:48 Z LucaIlie Norela (info1cup18_norela) C
0 / 100
16 ms 280 KB
#include <stdio.h>

#define MAX_M 24

int spell[MAX_M];

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

    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] += (1 << (p - 1));
        }
    }

    minUsedSpells = n + 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 = xor ^ spell[i];
                usedSpells++;
            }
        }
        if ( xor == (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:10:5: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   10 |     scanf( "%d%d", &n, &m );
      |     ^~~~~~~~~~~~~~~~~~~~~~~
norela.c:12:9: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   12 |         scanf( "%d", &k );
      |         ^~~~~~~~~~~~~~~~~
norela.c:15:13: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   15 |             scanf( "%d", &p );
      |             ^~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 16 ms 204 KB Output is correct
2 Incorrect 16 ms 280 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 16 ms 204 KB Output is correct
2 Incorrect 16 ms 280 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 16 ms 204 KB Output is correct
2 Incorrect 16 ms 280 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 16 ms 204 KB Output is correct
2 Incorrect 16 ms 280 KB Output isn't correct
3 Halted 0 ms 0 KB -