题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4749

Problem Description



  2013 is the 60 anniversary of Nanjing University of Science and Technology, and today happens to be the anniversary date. On this happy festival, school authority hopes that the new students to be trained for the parade show. You should plan a better solution
to arrange the students by choosing some queues from them preparing the parade show. (one student only in one queue or not be chosen)

  Every student has its own number, from 1 to n. (1<=n<=10^5), and they are standing from 1 to n in the increasing order the same with their number order. According to requirement of school authority, every queue is consisted of exactly m students. Because
students who stand adjacent in training are assigned consecutive number, for better arrangement, you will choose in students with in consecutive numbers. When you choose these m students, you will rearrange their numbers from 1 to m, in the same order with
their initial one. 

  If we divide our students’ heights into k (1<=k<=25) level, experience says that there will exist an best viewing module, represented by an array a[]. a[i] (1<=i<=m)stands for the student’s height with number i. In fact, inside a queue, for every number pair
i, j (1<=i,j<=m), if the relative bigger or smaller or equal to relationship between the height of student number i and the height of student number j is the same with that between a[i] and a[j], then the queue is well designed. Given n students’ height array
x[] (1<=x[i]<=k), and the best viewing module array a[], how many well designed queues can we make at most?

 
Input
Multiple cases, end with EOF.

First line, 3 integers, n (1<=n<=10^5) m (1<=m<=n) k(1<=k<=25),

Second line, n students’ height array x[] (1<=x[i]<=k,1<=i<=n);

Third line, m integers, best viewing module array a[] (1<=a[i]<=k,1<=i<=m);
 
Output
One integer, the maximal amount of well designed queues.
 
Sample Input
10 5 10
2 4 2 4 2 4 2 4 2 4
1 2 1 2 1
 
Sample Output
1
 
Source

题意:

给出了一列数,再给出了一列參照的数列其每一个数代表一个高度且须满足大小关系。求能够将所给的数列切割成多少个满足參照数列个数和高度的数列!

PS:

数据太水了。暴力过了!

正解貌似是KMP, 算了日后再补正解吧!

代码例如以下:

#include <cstdio>
#include <cstring>
#include <algorithm>
#include <iostream>
using namespace std;
const int maxn = 100017;
int a[maxn], b[maxn]; int main()
{
int n, m, k;
while(~scanf("%d%d%d",&n,&m,&k))
{
for(int i = 0; i < n; i++)
{
scanf("%d",&a[i]);
}
for(int i = 0; i < m; i++)
{
scanf("%d",&b[i]);
}
int cont = 0;
for(int i = 0; i <= n-m; i++)
{
int tt = 0;
for(int j = 0,l = i; l < m+i-1; l++,j++)
{
if((a[l]==a[l+1]&&b[j]==b[j+1]) || (a[l]>a[l+1]&&b[j]>b[j+1]) || (a[l]<a[l+1]&&b[j]<b[j+1]))
{
tt++;
}
else
break;
}
if(tt == m-1)
{
cont++;
i+=m-1;
}
}
printf("%d\n",cont);
}
return 0;
}

HDU 4749 Parade Show(暴力水果)的更多相关文章

  1. HDU 4749 Parade Show 2013 ACM/ICPC Asia Regional Nanjing Online

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4749 题目大意:给一个原序列N,再给出一个序列M,问从N中一共可以找出多少个长度为m的序列,序列中的数 ...

  2. HDU 4749 Parade Show(贪心+kmp)

    题目链接 题目都看不懂,做毛线...看懂了之后就是kmp出,所有的匹配区间,然后DP可以写,贪心也可以做把,DP应该需要优化一下,直接贪,也应该对的,经典贪心问题. #include<iostr ...

  3. HDU 4749: Parade Show

    看大神代码,发现上交大神很棒的一个思路 题意: 在源数字串中找出尽量多的连续子串,要求子串任意两值的大小关系与目标串相同位置的值的大小关系相同.求源串能拿出的子串的最大数量. 关键词: RK-Hash ...

  4. hdu 5461 Largest Point 暴力

    Largest Point Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pid= ...

  5. hdu 5762 Teacher Bo 暴力

    Teacher Bo 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5762 Description Teacher BoBo is a geogra ...

  6. HDU 1333 基础数论 暴力

    定义一种数位simth数,该数的各位之和等于其所有质因子所有位数字之和,现给出n求大于n的最小该种数,n最大不超过8位,那么直接暴力就可以了. /** @Date : 2017-09-08 14:12 ...

  7. HDU 4618 Palindrome Sub-Array 暴力

    Palindrome Sub-Array 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=4618 Description A palindrome s ...

  8. HDU 2089 不要62 | 暴力(其实是个DP)

    题目: http://acm.hdu.edu.cn/showproblem.php?pid=2089 题解: 暴力水过 #include<cstdio> #include<algor ...

  9. HDU 6115 Factory LCA,暴力

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6115 题意:中文题面 分析:直接维护LCA,然后暴力枚举集合维护答案即可. #include < ...

随机推荐

  1. php常量,提前定义常量,魔术常量及基本数据类型

    常量 定义: 形式一 // define("PI",常量值); define("PI",3.14); define("school",&qu ...

  2. UVA 10196 Morning Walk(欧拉回路)

    Problem H Morning Walk Time Limit 3 Seconds Kamalis a Motashotaguy. He has got a new job in Chittago ...

  3. validate命令---rman进行备份和回复的验证

    rman作为oracle备份与恢复工具,为我们提供了强大的功能.当中包含对数据文件的物理和逻辑检測以及备份文件的有效性检測. 首先.来看一下rman对数据文件的检測. 我们知道,rman在备份数据时, ...

  4. Java-杂项: Java中Array和ArrayList区别

    ylbtech-Java-杂项: Java中Array和ArrayList区别 1.返回顶部 1. 1)精辟阐述:可以将 ArrayList想象成一种“会自动扩增容量的Array”. 2)Array( ...

  5. CXF2.7.7 java.lang.RuntimeException: Cannot create a secure XMLInputFactory

    cxf-2.7.7.jar neethi-3.0.2.jar stax2-api-3.1.1.jar woodstox-core-asl-4.2.0.jar wsdl4j-1.6.3.jar xmls ...

  6. Windows下慎用内核隔离

    1. 开启内核隔离后只能通过注册表关闭   2. 开启内核隔离后, 默认会启动hybrid-v, 这个东西和虚拟机是冲突的, 这样就用不了虚拟机了.   3. 解决方法: 关闭内核隔离后, 再关闭已经 ...

  7. 切换JDK版本quick

    最近遇到一个小问题,同时做两个项目,jdk版本一个是5,一个是6,我也去网上找了找方法,但是感觉不是特别好用,最后自己通过一些环境变量设置的技巧和一些批处理命令来使得这件事情只需要双击,输入一个数字回 ...

  8. Swagger 隐藏具体API

    一.why 在swagger ui界面中有时候不想显示某些api,通过下面的方式可以实现. 1.1.新建一个类实现IDocumentFilter接口 using Swashbuckle.Swagger ...

  9. JS进阶 - 浏览器工作原理

    一.浏览器的结构 浏览器的主要组件为: 用户界面 - 包括地址栏.前进/后退按钮.书签菜单等.除了浏览器主窗口(显示页面),其他部分都属于用户界面. 浏览器引擎 - 在用户界面和渲染引擎之间传送指令. ...

  10. 【工作细节记录】维护项目中前端JS组件丢失后,应如何维护开发之启发

    事因: 我所维护的项目为旧项目,接手项目后并没有什么开发文档留下,导致很多时候一出现问题就需要自己去研究整个过程. 项目中一直使用一个"$.download()"的方法进行文件下载 ...