Submission #467535

#TimeUsernameProblemLanguageResultExecution timeMemory
467535LucaIlieNorela (info1cup18_norela)C11
75 / 100
1093 ms324 KiB
#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[m - 1 - i];
                usedSpells++;
            }
        }
        if ( xor == ((long long)1 << n) - 1 ) {
            if ( usedSpells <= minUsedSpells ) {
                minUsedSpells = usedSpells;
                solMask = mask;
            }
        }
    }

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

    return 0;
}

Compilation message (stderr)

norela.c: In function 'main':
norela.c:11:5: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   11 |     scanf( "%d%d", &n, &m );
      |     ^~~~~~~~~~~~~~~~~~~~~~~
norela.c:13:9: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |         scanf( "%d", &k );
      |         ^~~~~~~~~~~~~~~~~
norela.c:16:13: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   16 |             scanf( "%d", &p );
      |             ^~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...