• HDU5972Regular Number(ShiftAnd算法 bitset)


    题意

    题目链接

    第一行的(n)表示模式串长度为(n)

    接下来(n)行,每行开头有一个整数(num)表示匹配串中该位置的字符可以在(num)个桅子花出现,接下来输入这(num)个位置

    最后一行一个模式串

    Sol

    "It contains a set of test data"的意思原来是说只有一组测试数据

    ShiftAnd算法,非常interesting,推荐一篇讲的非常好的blog

    这题就是给出了(B)数组,然后暴力搞一下就行了。。

    垃圾题目卡我读入卡我输出

    #include<bits/stdc++.h>
    #define chmax(a, b) (a = (a > b ? a : b))
    #define chmin(a, b) (a = (a < b ? a : b))
    #define LL long long
    //#define int long long 
    using namespace std;
    const int MAXN = 5e6 + 10;
    inline int read() {
        int x = 0, f = 1; char c = getchar();
        while(c < '0' || c > '9') {if(c == '-') f = -1; c = getchar();}
        while(c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
        return x * f;
    }
    int N;
    char s[MAXN], tmp = '';
    bitset<1001> b[11], ans;
    void solve() {
        for(int i = 0; i <= N; i++) b[i].reset(); ans.reset();
        for(int i = 0; i < N; i++) {
            int num = read();
            for(int j = 0; j < num; j++) b[read()].set(i);
        }
        gets(s);
        int L = strlen(s);
        for(int i = 0; i < L; i++) {
            ans <<= 1; ans.set(0);
            ans &= b[s[i] - '0'];
            if(ans[N - 1] == 1) swap(s[i + 1], tmp), puts(s + i - N + 1), swap(s[i + 1], tmp);
        }
    }
    main() {
      scanf("%d", &N); solve();
    }
    /*
    4
    3 0 9 7
    2 5 7
    2 2 5
    2 4 5
    09755420524
    */
    
  • 相关阅读:
    第八周学习进度
    个人NABCD
    软件需求模式阅读笔记一
    问题账户需求分析
    2017年秋季个人阅读计划
    软件需求与分析——读后感
    第十六周周总结
    第十五周周总结
    第十四周周总结
    第十三周周总结
  • 原文地址:https://www.cnblogs.com/zwfymqz/p/9764322.html
Copyright © 2020-2023  润新知