题目链接: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. java中super的作用

    super()的作用 super能够用来訪问超类的构造方法和被子类所隐藏的方法.假设子类中有方法与超类中的方法名称和參数同样,则超类中的方法就被隐藏起来,也就是说在子类中重载了父类中的方法. 引用父类 ...

  2. EOJ 3124 单词表

    题目描述 提取英文文本中的单词,重复出现的单词只取一个,把它们按照字典顺序排序,建立为一个单词表. 例如:英文文本如下: “ask not what your country can do for y ...

  3. Oracle 查看锁定表用户的SQL

    #描述:当执行如下SQL select * From XXX for Updata 发现表“XXX”被锁定 #只需要执行如下SQL 查看锁定该表的用户 SELECT object_name, mach ...

  4. 4.matlab基础

    1 函数句柄 clear all; f1=@cos t=:pi/:pi f1(t) f2=@complex f2(,) clear all %函数句柄 f1=@char %函数句柄转换为字符串 s1= ...

  5. maven 项目加载本地JAR

     将jar安装到本地的maven仓库 1.首先确定本地有maven环境. 2.安装本地jar 模板: mvn install:install-file -Dfile=<path-to-file& ...

  6. Linux top命令简解

    简介: top 命令是最流行的性能监视工具之一,它是一个优秀的交互式工具,用于监视性能.它提供系统整体性能,但报告进程信息才是 top 命令的长处. top 界面分为两个部份,光标上面部份显示关于系统 ...

  7. java同步锁的正确使用

    同步锁分类 对象锁(this) 类锁(类的字节码文件对象即类名.class) 字符串锁(比较特别) 应用场景 在多线程下对共享资源的安全操作. 需求:启动5个线程对共享资源total进行安全操作. 同 ...

  8. Java回忆录之英勇黄铜V

    说实话最近心好累,就因为一个混合app开发贼简单的一个功能.我本以为很简单,做起来却发现需要很多知识面.麻雀虽小五脏俱全,即使再小的一个功能实现起来也需要很全面的知识来担保.要想盖高楼大厦啊必定要有坚 ...

  9. oc与swift比较

    swift试是用语言层面的雕虫小技和oc的机制大道进行pk. 从整体上来说,oc是一个更加优秀的语言.

  10. hdu 1080 dp(最长公共子序列变形)

    题意: 输入俩个字符串,怎样变换使其所有字符对和最大.(字符只有'A','C','G','T','-') 其中每对字符对应的值如下: 怎样配使和最大呢. 比如: A G T G A T G -  G ...