Submission #467536

# Submission time Handle Problem Language Result Execution time Memory
467536 2021-08-23T13:10:22 Z LucaIlie Norela (info1cup18_norela) C
0 / 100
1 ms 204 KB
#include <stdio.h>

#define MAX_M 24

struct aaa {
    int xor, usedSpells;
};

struct aaa v[1 << (MAX_M / 2)];

long long spell[MAX_M];

int main() {
    int n, m, k, p, minUsedSpells, usedSpells, solMask, mask1, mask2, 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));
        }
        printf( "%lld\n", spell[i] );
    }

    for ( mask1 = 0; mask1 < (1 << (m / 2)); mask1++ ) {
        xor = 0;
        usedSpells = 0;
        for ( i = 0; i < m / 2; i++ ) {
            if ( ((mask1 >> i) & 1) == 1 ) {
                xor ^= spell[i];
                usedSpells++;
            }
        }
        v[mask1].xor = xor;
        v[mask1].usedSpells = usedSpells;
    }
    minUsedSpells = m + 1;
    solMask = -1;
    for ( mask2 = 0; mask2 < (1 << (m - m / 2)); mask2++ ) {
        xor = 0;
        usedSpells = 0;
        for ( i = 0; i < m - m / 2; i++ ) {
            if ( ((mask2 >> i) & 1) == 1 ) {
                xor ^= spell[i + m / 2];
                usedSpells++;
            }
        }
        for ( mask1 = 0; mask1 < (1 << (m / 2)); mask1++ ) {
            if ( (v[mask1].xor ^ xor) == ((long long)1 << n) - 1 ) {
                if ( v[mask1].usedSpells + usedSpells < minUsedSpells ) {
                    minUsedSpells = v[mask1].usedSpells + usedSpells;
                    solMask = mask1 + mask2 * (1 << m / 2);
                }
            }
        }
    }

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

    return 0;
}

Compilation message

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