题目链接: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. ubuntu中写一个shell脚本的过程

    gedit hello.sh ,然后输入 #!/bin/bash echo "Hello world!" chmod +x hello.sh ./hello.sh

  2. hadoop(八) - hbase集群环境搭建

    1. 上传hbase安装包hbase-0.96.2-hadoop2-bin.tar.gz 2. 解压 tar -zxvf hbase-0.96.2-hadoop2-bin.tar.gz -C /clo ...

  3. NSAttributedString编程

    - (void)viewDidLoad {     [super viewDidLoad];          NSMutableAttributedString *attributedString ...

  4. windows安装mysql注意点

    MySQL安装文件分为两种,一种是msi格式的,一种是zip格式的. 以msi格式安装完成后,先别忙着启动mysql,我们还需要修改一下配置文件(如果没有配置,之后启动的时候就会出现图中的错误哦!:错 ...

  5. Spark RDD概念学习系列之Pair RDD的transformation操作

    不多说,直接上干货! Pair RDD的transformation操作 Pair RDD转换操作1 Pair RDD 可以使用所有标准RDD 上转化操作,还提供了特有的转换操作. Pair RDD转 ...

  6. Java基础——GridBagLayout布局

    1.GridBagLayout布局管理器非常灵活,每个 GridBagLayout 对象维持一个动态的矩形单元网格: 2.需要和它的约束类(GridBagConstraints类)一起使用: 3.Gr ...

  7. javascript中DOM基础知识介绍

    1.1.     基本概念 1.1.1.      DOM DOM Document Object Model 文档对象模型 就是把HTML文档模型化,当作对象来处理 DOM提供的一系列属性和方法可以 ...

  8. 第五章 Python之装饰器

    函数对象 函数是第一类对象:即函数可以当作数据传递 #可以被引用,可以被当作参数传递,返回值可以是函数,可以当作容器类型的元素 #引用 def func(x,y): print(x,y) f=func ...

  9. JavaScript中必记英语单词及含义

    reflow[ri'flo]:回流,重构(通过css改变页面的结构,比如一行元素,其中一个元素的高改变了,那么其他元素的位置也都会改变) repaint['ripent]:重绘(只改变页面的样式,比如 ...

  10. VMware虚拟机共享文件夹

    安装好虚拟文件夹后,第二次开机时发现/mnt/hgfs目录下找不到共享的文件夹,原因是vmfg-fuse服务没有开启. 在root的配置文件中添加如下代码,设置开机自启: /usr/bin/vmhgf ...