hdu 4749 Parade Show (暴力水 (正解应该是kmp变形))
来源:互联网 发布:天盾苹果手机数据恢复软件 编辑:程序博客网 时间:2024/05/16 00:27
Parade Show
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65535/65535 K (Java/Others)Total Submission(s): 2085 Accepted Submission(s): 843
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);
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 102 4 2 4 2 4 2 4 2 41 2 1 2 1
Sample Output
1
Source
#include<stdio.h>#include<string.h>#include<algorithm>using namespace std;int a[100003];int b[100003];int main(){ int n,m,k; while(~scanf("%d%d%d",&n,&m,&k)) { for(int i=1; i<=n; i++) { scanf("%d",&a[i]); } for(int i=1; i<=m; i++) { scanf("%d",&b[i]); } int i,j,l,res=0; int r=n-m+1; for(i=1; i<=r; i++) { int rr=i+m-1; for(j=1,l=i; j<m&&l<rr; j++,l++) { if((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]&&a[l]==a[l+1])) continue; else break; } if(j==m) res++,i=l; } printf("%d\n",res); }}
阅读全文
0 0
- hdu 4749 Parade Show (暴力水 (正解应该是kmp变形))
- HDU 4749 Parade Show(KMP变形)
- HDU 4749 Parade Show 数据结构KMP变形
- HDU 4749 Parade Show(暴力水果)
- HDU 4749 Parade Show(KMP)
- hdu-4749:Parade Show(kmp模板题)
- hdu 4749 Parade Show ( kmp )
- hdu 4749 Parade Show KMP
- hdu 4749 Parade Show(KMP)
- HDU 4749 Parade Show Kmp
- HDOJ 题目 4749 Parade Show(KMP)
- Hdu-4749 Parade Show
- HDU 4749 Parade Show 相对匹配的KMP
- Hdu 3687 National Day Parade(暴力)
- HDU 3687 National Day Parade(暴力)
- hdu4749 Parade Show(kmp)
- Poj 3167 Cow Patterns Hdu 4749 Parade Show (KMP大小关系相同匹配+树状数组)
- 军训选队伍 相对顺序匹配 kmp hdu 4749 Parade Show
- 奥赛培训总结
- 深度学习网络调试技巧_01
- HDU
- 文章标题
- POJ
- hdu 4749 Parade Show (暴力水 (正解应该是kmp变形))
- OPENCV编译Videoio模块问题解决
- Morris遍历求解二叉树前中后序遍历
- ExoPlayer Talk 01 缓存策略分析与优化
- memcache、redis原理对比
- 深度学习网络调参技巧_02
- 在Qt 5.9.1通过qt.conf指定共享库路径部署应用程序
- map函数,key相同的value存在list里,对dic进行排序
- 【leetcode】第46题 Permutations(递归法)题目+解析+代码