题意

题目链接

第一行的\(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 = '\0';
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
*/

HDU5972Regular Number(ShiftAnd算法 bitset)的更多相关文章

  1. hdu 5972 Regular Number 字符串Shift-And算法 + bitset

    题目链接 题意 给定两个串\(S,T\),找出\(S\)中所有与\(T\)匹配的子串. 这里,\(T\)的每位上可以有若干(\(\leq 10\))种选择,匹配的含义是:对于\(S\)的子串的每一位, ...

  2. [小专题]另一种字符串匹配的思路——Shift-And算法

    吐槽:前两天打组队赛遇到一个字符串的题考了这个(见:http://acm.hdu.edu.cn/showproblem.php?pid=5972 ) 当时写了个KMP瞎搞然后TLE了(害),赛后去查了 ...

  3. 【JZOJ5064】【GDOI2017第二轮模拟day2】友好城市 Kosarajo算法+bitset+ST表+分块

    题面 在Byteland 一共有n 座城市,编号依次为1 到n,这些城市之间通过m 条单向公路连接. 对于两座不同的城市a 和b,如果a 能通过这些单向道路直接或间接到达b,且b 也能如此到达a,那么 ...

  4. HDU 1711 Number Sequence(算法验证)

    该怎么做.每一个人的人生都应该自己掌握.你给不了别人一切.你也不懂别人的忧伤. 微笑不代表快乐.哭泣不一定悲伤 不努力怎么让关心你的人幸福.不努力怎么让看不起你的人绝望. 我用生命在奋斗--lx_Zz ...

  5. 2016 ACM-ICPC 区域赛(大连站)题解

    题目链接 A - Wrestling Match (二分图染色) 题意略坑(没有说好的玩家一定能打过差的玩家啊啊~~) 典型的二分图染色问题,每个玩家看成一个点,把相互较量过的玩家之间连边,好的玩家染 ...

  6. Regular Number 字符串匹配算法 Shift_and

    Using regular expression to define a numeric string is a very common thing. Generally, use the shape ...

  7. 每周一练 之 数据结构与算法(Stack)

    最近公司内部在开始做前端技术的技术分享,每周一个主题的 每周一练,以基础知识为主,感觉挺棒的,跟着团队的大佬们学习和复习一些知识,新人也可以多学习一些知识,也把团队内部学习氛围营造起来. 我接下来会开 ...

  8. Linux kernel的中断子系统之(三):IRQ number和中断描述符

    返回目录:<ARM-Linux中断系统>. 总结: 二描述了中断处理示意图,以及关中断.开中断,和IRQ number重要概念. 三介绍了三个重要的结构体,irq_desc.irq_dat ...

  9. Ugly Number leetcode java

    问题描述: Write a program to check whether a given number is an ugly number. Ugly numbers are positive n ...

随机推荐

  1. Shell-4-让文本飞

    1.正则表达式 ^ 行起始标志 $ 行尾标记 . 匹配任意一个字符 [ ] 匹配包含在[字符]之中的任意一个字符,coo[kl]匹配cook或cool [^] 匹配除[^字符]的任意一个字符 [-] ...

  2. Windows Server 2016 IIS10安装URLRewrite 2.0组件方法

    1,打开Regedit> HKEY_LOCAL_MACHINE \ SOFTWARE \ Microsoft \ InetStp2,编辑“MajorVersion”并以十进制设置数值数据值为93 ...

  3. SpringBoot dubbo之class is not visible from class loader

    使用了两个类加载器加载了同一个类,区分一个Class对象是否相等要看包名+类名,也要看是否是同一个类加载器 方案一,排查掉spring-boot-devtools模块的maven引入可以解决,这时候所 ...

  4. P3768 简单的数学题 杜教筛+推式子

    \(\color{#0066ff}{ 题目描述 }\) 由于出题人懒得写背景了,题目还是简单一点好. 输入一个整数n和一个整数p,你需要求出(\(\sum_{i=1}^n\sum_{j=1}^n ij ...

  5. atcoder 2579

    You are taking a computer-based examination. The examination consists of N questions, and the score ...

  6. 二创建maven父子项目

    关于maven中的parent聚合一直都有没好好总结,固有这篇. ------------------------------------------------------------------- ...

  7. How to pass multiple parameters in PowerShell invoke-restmethod

    Link: http://www.tagwith.com/question_322855_how-to-pass-parameters-in-powershell-invoke-restmethod- ...

  8. Visible Ops

    Link:http://www.wikisummaries.org/Visible_Ops Contents [hide]  1 What is ITIL? 2 Introduction 3 Phas ...

  9. Html背景图

    <table style="height: 210px;" ><tbody><tr><td style="background- ...

  10. Android + Appium 自动化测试完整的环境配置及代码详解

    环境的的搭建 参考大神博客:https://www.cnblogs.com/fnng/p/4540731.html 该博客有一套详细的入门教程,奈何时间有点久远有些东西不能用了,但是参考价值还是有滴. ...