hdu 5972---Regular Number(字符串匹配)
(0|9|7) (5|6) (2) (4|5)
Above regular expression matches 4 digits:The first is one of 0,9 and 7. The second is one of 5 and 6. The third is 2. And the fourth is one of 4 and 5. The above regular expression can be successfully matched to 0525, but it cannot be matched to 9634.
Now,giving you a regular expression like the above formula,and a long string of numbers,please find out all the substrings of this long string that can be matched to the regular expression.
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <bitset>
using namespace std;
typedef long long LL;
const int M=*1e6+;
bitset<>b[];
bitset<>ans;
char s[]; int main()
{
int N;
while(scanf("%d",&N)!=EOF)
{
for(int i=;i<;i++) b[i].reset();
for(int i=;i<N;i++)
{
int n;
scanf("%d",&n);
for(int j=;j<=n;j++)
{
int k;
scanf("%d",&k);
b[k].set(i);
}
}
getchar();
gets(s);
ans.reset();
int len=strlen(s);
for(int i=;i<len;i++)
{
ans=ans<<;
ans.set();
ans=ans&b[s[i]-''];
if(ans[N-]==){
char c=s[i+];
s[i+]='\0';
puts(s+i-N+);
s[i+]=c;
}
}
}
return ;
}
hdu 5972---Regular Number(字符串匹配)的更多相关文章
- HDU 5972 Regular Number
Regular Number http://acm.hdu.edu.cn/showproblem.php?pid=5972 题意: 给定一个字符串,求多少子串满足,子串的第i位,只能是给定的数(小于等 ...
- HDU 5972 Regular Number(ShiftAnd+读入优化)
[题目链接] http://acm.hdu.edu.cn/showproblem.php?pid=5972 [题目大意] 给出一个字符串,找出其中所有的符合特定模式的子串位置,符合特定模式是指,该子串 ...
- hdu 5972 Regular Number 字符串Shift-And算法 + bitset
题目链接 题意 给定两个串\(S,T\),找出\(S\)中所有与\(T\)匹配的子串. 这里,\(T\)的每位上可以有若干(\(\leq 10\))种选择,匹配的含义是:对于\(S\)的子串的每一位, ...
- HDU 5972 Regular Number(字符串shift - and算法)
题目链接 HDU5972 2016 ACM/ICPC 大连区域赛 B题 我们预处理出$b[i][j]$,$b[i][j] = 1$的意义是数字$i$可以放在第$j$位. 然后就开始这个匹配的过程. ...
- HDU 1711 Number Sequence (字符串匹配,KMP算法)
HDU 1711 Number Sequence (字符串匹配,KMP算法) Description Given two sequences of numbers : a1, a2, ...... , ...
- HDU 1686 Oulipo / POJ 3461 Oulipo / SCU 2652 Oulipo (字符串匹配,KMP)
HDU 1686 Oulipo / POJ 3461 Oulipo / SCU 2652 Oulipo (字符串匹配,KMP) Description The French author George ...
- HDU 1711(KMP)字符串匹配
链接 HDU 1711 Number Sequence KMP 算法 我以自己理解写的,写的不对,不明白的地方海王子出来,一起共同学习: 字符串匹配 就是KMP,一般思想,用一个for循环找开头 ...
- HDU 5716 带可选字符的多字符串匹配(ShiftAnd)
[题目链接] http://acm.hdu.edu.cn/showproblem.php?pid=5716 [题目大意] 给出一个字符串,找出其中所有的符合特定模式的子串位置,符合特定模式是指,该子串 ...
- HDU 2087 剪花布条(字符串匹配,KMP)
HDU 2087 剪花布条(字符串匹配,KMP) Description 一块花布条,里面有些图案,另有一块直接可用的小饰条,里面也有一些图案.对于给定的花布条和小饰条,计算一下能从花布条中尽可能剪出 ...
随机推荐
- django.core.exceptions.ImproperlyConfigured: Requested setting DEFAULT_INDEX_TABLESPACE, but settings are not configured. You must either define the environment variable DJANGO_SETTINGS_MODULE or call
Error info: django.core.exceptions.ImproperlyConfigured: Requested setting DEFAULT_INDEX_TABLESPACE, ...
- 查看sql 语句io执行情况
set statistics io,time on 表 'xx'.扫描计数 1,逻辑读取 19 次,物理读取 0 次,预读 0 次,lob 逻辑读取 76 次,lob 物理读取 0 次,lob 预读 ...
- Solr定时导入功能实现
需要实现Solr定时导入功能的话,我们可以通过使用Solr自身所集成的dataimportscheduler调度器实现 下载对应的jar包,下载地址https://code.google.com/ar ...
- mySQL安装与基础配置
关系型数据库介绍 数据结构模型 数据结构模型主要有: 层次模型 网状结构 关系模型 关系模型: 二维关系:row,column 数据库管理系统:DBMS 关系:Relational,RDBMS RDB ...
- Samba简介与配置(匿名&本地用户验证)
Samba简介 Samba是在Linux和UNIX系统上实现SMB协议的一个免费软件,由服务器及客户端程序构成. 在此之前我们已经了解了NFS,NFS与samba一样,也是在网络中实现文件共享的一种实 ...
- java28
1.使用多态的优点 把要创建的多个子类缩减为一个父类接着传入参数,用参数调用子类的方法, 输出时直接调用父类的方法,这时传参传创建的对象 2.多态方法的调用 调用的方法前有static时,会默认调用父 ...
- Python day 4
阅读目录 内容回顾: 流程控制: if分支结构: while循环控制: for循环(迭代器): ##内容回顾: #1.变量名命名规范 -- 1.只能由数字.字母 及 _ 组成 -- 2.不能以数字开头 ...
- 加盟阿里!贾扬清被曝从Facebook离职,任阿里硅谷研究院VP
3 月 2 日傍晚,知乎上爆出一则 AI 人事变动大消息——Caffe 作者贾扬清将从 Facebook 离职. 短短数小时,就有近 10 万人浏览这个问题.不仅如此,据 AI 前线爆料,贾扬清离开 ...
- PHP字符串函数之 strpos stripos strrpos strripos
strpos – 查找字符串首次出现的位置 stripos – 查找字符串首次出现的位置(不区分大小写) strrpos – 计算指定字符串在目标字符串中最后一次出现的位置 strripos – 计算 ...
- CentOS操作系统防火墙添加例外端口
http://blog.csdn.net/inrgihc/article/details/63392004 CentOS6与CentOS7添加防火墙例外端口的命令不用,需单独来说: (1)CentOS ...