hdu 5745 La Vie en rose(2016多校第二场)
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
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 .
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.
n . The i -th character is "1" if and only if the substring sisi+1...si+m−1 is one of the generated patterns.
#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多校第二场)的更多相关文章
- HDU 5745 La Vie en rose 暴力
La Vie en rose 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5745 Description Professor Zhang woul ...
- 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 ...
- HDU 5745 La Vie en rose (DP||模拟) 2016杭电多校联合第二场
题目:传送门. 这是一道阅读理解题,正解是DP,实际上模拟就能做.pij+1 指的是 (pij)+1不是 pi(j+1),判断能否交换输出即可. #include <iostream> # ...
- hdu 5745 La Vie en rose DP + bitset优化
http://acm.hdu.edu.cn/showproblem.php?pid=5745 这题好劲爆啊.dp容易想,但是要bitset优化,就想不到了. 先放一个tle的dp.复杂度O(n * m ...
- hdu 5744 Keep On Movin (2016多校第二场)
Keep On Movin Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Tot ...
- hdu5745 La Vie en rose 巧妙地dp+bitset优化+滚动数组减少内存
/** 题目:hdu5745 La Vie en rose 链接:http://acm.hdu.edu.cn/showproblem.php?pid=5745 题意:题目给出的变换规则其实就是交换相邻 ...
- La Vie en rose (模拟)
#include<bits/stdc++.h> using namespace std; ; ; int T, n, m; char str1[maxm], str2[maxn]; int ...
- hdu 5734 Acperience(2016多校第二场)
Acperience Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total ...
- 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 ...
随机推荐
- python实例 输出你好
#打开新窗口,输入: #! /usr/bin/python # -*- coding: utf8 -*- s1=input("Input your name:") print(&q ...
- agc015D A or...or B Problem
题意:求用若干个(至少一个)[A,B]中的数进行or操作能得到多少本质不同的数 $1 \leq A \leq B < 2^{60}$ 一直在想数位dp,看了题解之后感觉自己就是个sb 我们先把$ ...
- vue使用填坑之生命周期钩子的 this 上下文
每个Vue实例在被创建的时候都需要经过一系列的初始过程,如设置数据监听,编译模版,将实例挂载到DOM并在数据变化的时候更新DOM.在这个过程中,也会运行一些叫生命周期钩子的函数.如created, m ...
- MyEclipse优化】-----如何合理设置MyEclipse中的validation选项
打开eclipse,点击[window]菜单,选择[preferences]选项. 在左侧点击[validation]选项,在右侧可以看到eclipse进行的自动检查都有哪些内容. 将Manual(手 ...
- etree不存在解决方法
from lxml import html text=xxx//测试的html文本 etree = html.etree htmlDiv = etree.HTML(text) title = html ...
- 跟阿根一起学Java Web开发二:使用Ajax技术及XML与JSON实现输出
如今B/S结构的系统使用Ajax技术是再平常只是的了.今天我们就来探讨下在JSPGenSDF第四版中:怎样使用Ajax技术.怎样输出XML文件及JSON格式数据输出. 怎样搭建一个最基础的JSPGen ...
- Spring boot--控制器增强
在Spring3.2中,新增了@ControllerAdvice注解.关于这个注解的官方说明https://docs.spring.io/spring-framework/docs/5.0.0.M1/ ...
- POJ1485 Sumdiv
Sumdiv Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 22680 Accepted: 5660 Descripti ...
- 洛谷 P1266 速度限制 最短路+SPFA算法
目录 题面 题目链接 题目描述 输入输出格式 输入格式 输出格式 输入输出样例 输入样例 输出样例 说明 思路 AC代码 题面 题目链接 P1266 速度限制 题目描述 在这个繁忙的社会中,我们往往不 ...
- Spring_自动组件扫描和 基于注解配置bean
自动组件扫描 启用Spring组件扫描功能. 使用@Component注释来表示这是类是一个自动扫描组件. package com.tanlei.dao; import org.springfram ...