• 【HDOJ】3006 The Number of set


    数据量这么小,果断状态压缩+dp。

     1 /* 3006 */
     2 #include <iostream>
     3 #include <string>
     4 #include <map>
     5 #include <queue>
     6 #include <set>
     7 #include <stack>
     8 #include <vector>
     9 #include <deque>
    10 #include <algorithm>
    11 #include <cstdio>
    12 #include <cmath>
    13 #include <ctime>
    14 #include <cstring>
    15 #include <climits>
    16 #include <cctype>
    17 #include <cassert>
    18 #include <functional>
    19 using namespace std;
    20 //#pragma comment(linker,"/STACK:102400000,1024000")
    21 
    22 #define mpii            map<int,int>
    23 #define vi                vector<int>
    24 #define pii                pair<int,int>
    25 #define vpii            vector<pair<int,int> >
    26 #define rep(i, a, n)     for (int i=a;i<n;++i)
    27 #define per(i, a, n)     for (int i=n-1;i>=a;--i)
    28 #define pb                 push_back
    29 #define mp                 make_pair
    30 #define fir                first
    31 #define sec                second
    32 #define all(x)             (x).begin(),(x).end()
    33 #define SZ(x)             ((int)(x).size())
    34 #define lson            l, mid, rt<<1
    35 #define rson            mid+1, r, rt<<1|1
    36 
    37 const int N = 105;
    38 const int maxn = (2<<14)+1;
    39 bool visit[maxn];
    40 int sft[15];
    41 
    42 int main() {
    43     ios::sync_with_stdio(false);
    44     #ifndef ONLINE_JUDGE
    45         freopen("data.in", "r", stdin);
    46         freopen("data.out", "w", stdout);
    47     #endif
    48     
    49     int n, m;
    50     int x, nn;
    51     int ans, tmp;
    52     
    53     sft[1] = 1;
    54     rep(i, 2, 15)
    55         sft[i] = sft[i-1] << 1;
    56     
    57     memset(visit, false, sizeof(visit));
    58     while (scanf("%d %d", &n, &m)!=EOF) {
    59         memset(visit, false, sizeof(visit));
    60         visit[0] = true;
    61         rep(i, 0, n) {
    62             scanf("%d", &nn);
    63             tmp = 0;
    64             while (nn--) {
    65                 scanf("%d", &x);
    66                 tmp |= sft[x];
    67             }
    68             per(j, 0, maxn) {
    69                 if (visit[j]) {
    70                     visit[j|tmp] = true;
    71                 }
    72             }
    73         }
    74         
    75         ans = 0;
    76         rep(j, 1, maxn)
    77             ans += visit[j];
    78         printf("%d
    ", ans);
    79     }
    80     
    81     #ifndef ONLINE_JUDGE
    82         printf("time = %d.
    ", (int)clock());
    83     #endif
    84     
    85     return 0;
    86 }
  • 相关阅读:
    快速幂模板
    ACM大一寒假集训week1.2
    ACM大一寒假集训week1.1
    Gym
    Gym
    大学ACM第八周心得
    大学ACM第六周心得(11.29)
    大学ACM第五周心得
    大学ACM第四周心得
    大学ACM第三周心得
  • 原文地址:https://www.cnblogs.com/bombe1013/p/4606824.html
Copyright © 2020-2023  润新知