zoukankan      html  css  js  c++  java
  • CF383E Vowels

    CF383E

    (虽然 (24) 有点大,但是我们有 (4) 秒!!!)看数据范围,(2^{24}) 枚举,似乎是可以做的(大概(2 cdot 10^7))那么我们考虑子集dp(但是这题的复杂度好像是 (O(nlog n)),不知道为啥能过。)

    #include <iostream>
    #include <cstring>
    #include <cstdio>
    
    using namespace std;
    
    typedef int ll;
    const ll MAXN = 1e6+10, MAXM = 24;
    
    ll N, M, f[(1U << MAXM) + 10], bit[(1U << MAXM) + 10];
    unsigned long long ans = 0;
    char ss[5];
    
    int main() {
        for (unsigned int i = 0; i < (1U << MAXM); i++) 
            bit[i] = bit[i>>1]+(i&1);
        scanf("%d", &N);
        for (ll i = 1; i <= N; i++) {
            scanf("%s", ss+1);
            unsigned int t = 0;
            for (ll j = 1; j <= 3; j++) {
                ll now = ss[j] - 'a';
                t |= (1U << now);
            }
            for (unsigned int j = t; j; j = (j-1)&t)
                if (bit[j] & 1) f[j]++;
                else f[j]--; 
        }
        for (ll j = 0; j < MAXM; j++)
            for (unsigned int i = 0; i < (1U << MAXM); i++)
                if (i & (1U << j))
                    f[i] += f[i^(1U << j)];
        for (unsigned int i = 0; i < (1U << MAXM); i++) 
            ans ^= 1ULL * f[i] * f[i];
        printf("%llu", ans);
        return 0;
    }
    
  • 相关阅读:
    springmvc
    POJ 3683 Priest John's Busiest Day
    POJ 3678 Katu Puzzle
    HDU 1815 Building roads
    CDOJ UESTC 1220 The Battle of Guandu
    HDU 3715 Go Deeper
    HDU 3622 Bomb Game
    POJ 3207 Ikki's Story IV
    POJ 3648 Wedding
    HDU 1814 Peaceful Commission
  • 原文地址:https://www.cnblogs.com/Gensokyo-Alice/p/13825272.html
Copyright © 2011-2022 走看看