La Vie en rose

Time Limit: 14000/7000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 643    Accepted Submission(s):
328

Problem Description
Professor Zhang would like to solve the multiple
pattern matching problem, but he only has only one pattern string p=p1p2...pm . So, he wants to generate as many as possible pattern strings from p using the following method:

1. select some indices i1,i2,...,ik such that 1≤i1<i2<...<ik<|p| and |ij−ij+1|>1 for all 1≤j<k .
2. swap pij and pij+1 for all 1≤j≤k .

Now, for a given a string s=s1s2...sn , Professor Zhang wants to find all occurrences of all the generated patterns in
s .

 
Input
There are multiple test cases. The first line of input
contains an integer T , indicating the number of test cases. For each test case:

The first line
contains two integers n and m (1≤n≤105,1≤m≤min{5000,n}) -- the length of s and p .

The second line contains the string s and the third line contains the string p . Both the strings consist of only lowercase English letters.

 
Output
For each test case, output a binary string of length
n . The i -th character is "1" if and only if the substring sisi+1...si+m−1 is one of the generated patterns.
 
Sample Input
3
4 1
abac
a
4 2
aaaa
aa
9 3
abcbacacb
abc
 
Sample Output
1010
1110
100100100
 
Author
zimpha
 
题意:输入两个字符串s串和p串,p串从s串的第一个字符开始一直比较到最后一个(如果后面字符比p串段,则肯定输出0),比较的时候若不相同,则p串的字符可以相邻交换进行比较,每个位置只能交换一次,(只是当前比较的交换,而不是永久交换),相同字符串输出1,不同则输出0。
 
纯暴力,从第一个字符开始比较就好。
 
附上代码:
 
 #include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#define ll long long
using namespace std;
char s1[],s2[];
int main()
{
int T,i,j;
scanf("%d",&T);
while(T--)
{
int len1,len2;
memset(s1,'\0',sizeof(s1));
memset(s2,'\0',sizeof(s2));
scanf("%d%d",&len1,&len2);
scanf("%s%s",s1,s2);
char w;
if(len1<len2)
{
for(i=; i<len1; i++)
printf("");
printf("\n");
continue;
}
for(i=; i<len1; i++)
{
int t=;
for(j=i; j<i+len2&&j<len1; j++)
{
if(s1[j]!=s2[t])
{
if(j==i+len2-)
break;
if(s1[j+]!=s2[t]||s1[j]!=s2[t+])
break;
else
{
t+=;
j+=;
}
}
else
{
t++;
}
}
if(j==i+len2)
printf("");
else
printf(""); }
printf("\n");
}
return ;
}

hdu 5745 La Vie en rose(2016多校第二场)的更多相关文章

  1. HDU 5745 La Vie en rose 暴力

    La Vie en rose 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5745 Description Professor Zhang woul ...

  2. HDU 5745 La Vie en rose

    La Vie en rose Time Limit: 14000/7000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)T ...

  3. HDU 5745 La Vie en rose (DP||模拟) 2016杭电多校联合第二场

    题目:传送门. 这是一道阅读理解题,正解是DP,实际上模拟就能做.pij+1 指的是 (pij)+1不是 pi(j+1),判断能否交换输出即可. #include <iostream> # ...

  4. hdu 5745 La Vie en rose DP + bitset优化

    http://acm.hdu.edu.cn/showproblem.php?pid=5745 这题好劲爆啊.dp容易想,但是要bitset优化,就想不到了. 先放一个tle的dp.复杂度O(n * m ...

  5. hdu 5744 Keep On Movin (2016多校第二场)

    Keep On Movin Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Tot ...

  6. hdu5745 La Vie en rose 巧妙地dp+bitset优化+滚动数组减少内存

    /** 题目:hdu5745 La Vie en rose 链接:http://acm.hdu.edu.cn/showproblem.php?pid=5745 题意:题目给出的变换规则其实就是交换相邻 ...

  7. La Vie en rose (模拟)

    #include<bits/stdc++.h> using namespace std; ; ; int T, n, m; char str1[maxm], str2[maxn]; int ...

  8. hdu 5734 Acperience(2016多校第二场)

    Acperience Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total ...

  9. hdu 5742 It's All In The Mind(2016多校第二场)

    It's All In The Mind Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Oth ...

随机推荐

  1. Linux 中查询 CPU 的核数的方法

    以一台 Linux 服务器为例.这台 Linux 包括两颗 Intel(R) Xeon(R) CPU E5-2630 v4 @ 2.20GHz CPU, 单颗 CPU 包括 10 个 cpu core ...

  2. 插头DP智障操作合集

    今天一共四道插头DP[其实都差不多],智障错误出了不下五个:D 来,让我好好数落我自己一下 直接写代码注释里吧 Eat the Trees #include<iostream> #incl ...

  3. oracle习题集-高级查询

    1.问题:查询每个员工的部门名称,列出员工姓名和部门名称 select e.ename,d.dname from emp e,dept d where e.deptno=d.deptno 2. 问题: ...

  4. php分页查询的简单实现代码

    <body><h1>分页查询</h1><?phpinclude("DADB.class.php");$db=new DADB();$tj= ...

  5. Linux安装MariaDB(Mysql)和简单配置 mariadb

    Linux安装MariaDB(Mysql)和简单配置 1.安装MariaDB 安装命令 yum -y install mariadb mariadb-server 安装完成MariaDB,首先启动Ma ...

  6. fedora安装mod_python

    3.1 Installing mod_python To install mod_python, we simply run: yum install mod_python 3.2 Configuri ...

  7. Codeforces Round #275 (Div. 2) A. Counterexample【数论/最大公约数】

    A. Counterexample time limit per test 1 second memory limit per test 256 megabytes input standard in ...

  8. SQL优化系列(三)- 用最少的索引获得最大的性能提升

    从全局出发优化索引 对于高负载的数据库,如何创建最少的索引,让数据库的整体性能提高呢?例如,对于100 条SQL语句,如何创建最佳的5条索引? SQL自动优化工具SQL Tuning Expert P ...

  9. R语言处理Web数据

    R语言处理Web数据 许多网站提供的数据,以供其用户的消费.例如,世界卫生组织(WHO)提供的CSV,TXT和XML文件的形式的健康和医疗信息报告.基于R程序,我们可以通过编程提取这些网站的具体数据. ...

  10. Polyfill简介

    1.什么是Polyfill? Polyfill是一个js库,主要抚平不同浏览器之间对js实现的差异.比如,html5的storage(session,local), 不同浏览器,不同版本,有些支持,有 ...