1045 Favorite Color Stripe (30 point(s))

OFDM时频脉冲形状与子载波正交性的理解 从多载波调制的角度来理解子载波间正交,首先要明确OFDM默认的脉冲成型是时域矩形窗,时域上每个子载波 ej2πfnte^{j2πf_nt}ej2πfn​t 都被一个矩形窗脉冲gT(t)g_T(t)gT​(t)成型。其次,OFDM子载波间隔 等于 OFDM符号周期的倒数,这是子载波正交的条件。 ​ 根据时频脉冲形状,可以从时域上理解如左图(注意是矩形脉冲 乘 复指数),从频域上理解如右图(sinc脉冲 卷 频点)。 ​ 阅读详情

1045 Favorite Color Stripe (30 point(s))

Eva is trying to make her own color stripe out of a given one. She would like to keep only her favorite colors in her favorite order by cutting off those unwanted pieces and sewing the remaining parts together to form her favorite color stripe.

It is said that a normal human eye can distinguish about less than 200 different colors, so Eva's favorite colors are limited. However the original stripe could be very long, and Eva would like to have the remaining favorite stripe with the maximum length. So she needs your help to find her the best result.

Note that the solution might not be unique, but you only have to tell her the maximum length. For example, given a stripe of colors {2 2 4 1 5 5 6 3 1 1 5 6}. If Eva's favorite colors are given in her favorite order as {2 3 1 5 6}, then she has 4 possible best solutions {2 2 1 1 1 5 6}, {2 2 1 5 5 5 6}, {2 2 1 5 5 6 6}, and {2 2 3 1 1 5 6}.

Input Specification:

Each input file contains one test case. For each case, the first line contains a positive integer N (≤200) which is the total number of colors involved (and hence the colors are numbered from 1 to N). Then the next line starts with a positive integer M (≤200) followed by M Eva's favorite color numbers given in her favorite order. Finally the third line starts with a positive integer L (≤10​4​​) which is the length of the given stripe, followed by L colors on the stripe. All the numbers in a line a separated by a space.

Output Specification:

For each test case, simply print in a line the maximum length of Eva's favorite stripe.

Sample Input:

6
5 2 3 1 5 6
12 2 2 4 1 5 5 6 3 1 1 5 6

Sample Output:

7

本质:动态规划。基于优先级的最长上升子串(LIS)。

相关链接:https://blog.youkuaiyun.com/coderwait/article/details/89679684

根据输入的favorite order进行优先级赋值,即先输入的优先级更高,后输入的优先级更低,优先级更低的只能出现在优先高的之后,不在favorite order中的不纳入考虑。

然后遍历每个元素,如果它在favorite order中,则再遍历之前的元素,如果priority[a[j]]<=priority[a[i]]则更新dp[]。dp[i]表示以第i个元素结尾的最长的满足要求的子串。最终的最长子串即为dp[]的最大值。

#include<iostream>
#include<cstring>
using namespace std;
const int MAX = 1e4+7;
int priority[207]={0};
int a[MAX];
int dp[MAX]={0};//以位置i结束的最长串 
int main(void){
	int N,M,L,x;cin>>N>>M;//total colors, favorite order
	for(int i=1;i<=M;i++){
		cin>>x;
		priority[x]=i;//优先级,正数且优先级越小越高 
	}
	cin>>L; 
	for(int i=0;i<L;i++) cin>>a[i];
	int maxLen=0; 
	for(int i=0;i<L;i++){
		if(priority[a[i]]>0){
			for(int j=0;j<i;j++){
				if(priority[a[j]]>0&&priority[a[j]]<=priority[a[i]]){
					dp[i]=max(dp[i],dp[j]+1);
				}
			}
			dp[i]=max(1,dp[i]);
			maxLen = max(maxLen,dp[i]);
		}
	} 
	cout<<maxLen<<endl; 
	return 0;
} 

 

破解现代反爬虫:JS加密、OB混淆与CSS反爬的实战攻防分析 摘要: 随着反爬技术的升级,JS加密、OB混淆和CSS反爬成为主流防护手段,阻碍传统爬虫获取数据。本文解析了这些技术的工作原理,并提出破解策略:通过模拟浏览器(如Selenium、Puppeteer)执行动态JS,逆向混淆代码,以及利用开发者工具突破CSS隐藏。针对复杂防护,开发者需结合技术分析与工具应用,如API接口抓取、动态渲染破解等,以应对不断演进的反爬机制。未来,爬虫攻防将持续升级,需保持技术敏锐性。 阅读详情

相关推荐

19-5 ACC 自适应巡航控制系统需求

本专题由深圳季连AIgraphX李博及团队出品,主要讲解ACC自适应巡航控制系统的开发与仿真测试。具体说来,包括ACC标准/法规分析、系统需求、系统架构、软件需求、软件架构、算法建模、验证场景分析、仿真实验搭建等内容。 本节主要讲ACC系统需求。

AIgraphX 1090

1045 Favorite Color Stripe(最长不下降子序列)

1045 Favorite Color Stripe(最长不下降子序列) 题意:按照题目给出的颜色序列找出原颜色序列中对应的子序列,给出的颜色序列不需要在子序列中全部出现。 解法:根据给出的序列对相应的颜色赋权值,就可以将颜色序列变成递增的权值序列,同样将原序列中出现的对应颜色变为相应权值,然后再找最长不下降子序列。(动态规划) #include <iostream> #include<map> #include<vector> #include<algorith

weixin_43842155的博客 261

Win10+pycharm+conda 配置Siammask 过程记录(新手向)

我们跑动demo 需要配置两个相关的文件这两个文件需要用 git 进行下载,对于不熟悉git的小伙伴 我这里给出连接,大家可以直接下载即可,并将其配置在 experiments文件夹下然后大家再需要在设置参数参数这里给出了。

C1137577723的博客 551

PAT甲级真题-1045 Favorite Color Stripe详解优化

1045 Favorite Color Stripe 题目链接 https://pintia.cn/problem-sets/994805342720868352/problems/994805437411475456 解题思路 代码展示 #include<bits/stdc++.h> using namespace std; /* 思路: */ struct node{ int aft; char c; bool flag; }; node ll[100000]; int m

高高冷的博客 535

【AI知识点】启发式算法(Heuristic Algorithms)

启发式算法(Heuristic Algorithms) 是一种基于经验、直觉和局部优化的求解问题的算法,尤其适用于解决计算复杂度高、规模庞大的问题。它们通过简化问题、局部搜索和快速近似,提供了一种在短时间内获得“足够好”解的途径。虽然启发式算法无法保证全局最优解,但它们在实际应用中广泛使用,特别是在优化问题、任务调度和机器学习等领域。

AI完全体 3033

计算机视觉安防监控升级:人脸识别与行为异常检测

计算机视觉安防监控升级:人脸识别与行为异常检测 ,人工智能,计算机视觉,大模型,AI,本文将深入探讨人脸识别与行为异常检测技术在安防监控中的应用,包括技术原理、算法实现、应用场景以及面临的挑战与解决方案。通过实际案例和代码示例,帮助读者更好地理解和掌握这些技术,为推动安防监控系统的智能化升级提供参考。

不踩坑,不知道坑有多深;不总结,踩过的坑白踩。 23万+

pat 甲级 1045 Favorite Color Stripe

则p[i]与s[j]都不选或任选其一,分别为f[i-1][j-1],f[i][j-1],f[i-1][j]。又因为f[i-1][j-1]包含在f[i][j-1],f[i-1][j]中。所以f[i][j]=max(f[i−1][j],f[i][j−1])2. p[i] == s[j],则包含p[i]与s[j]。由于p[i]可以重复,f[i][j]=max(f[i][j−1],f[i−1][j−1])+1。f[i-1][j-1]+1表示p[i]之前未在。f[i][j-1]+1则是p[i]已经在。

weixin_50671259的博客 581

245. 项目195:简易文字冒险游戏——《跟老吕学Python·新手》

如果您在学习本专栏教程时遇到任何问题,或有任何技术交流的意愿,欢迎在文章评论区留言,或通过优快云私信与老吕取得联系。老吕将及时回复您的留言,并与您共同探讨,以期为大家提供更为精准和有效的帮助。老吕珍视每一位读者的反馈和支持,期待与您共同学习、共同进步,共同创造美好的未来!我们的目标是不仅教会您Python语言,更是培养您解决问题的思维方式。请随意翻阅,按照自己的节奏学习,让这本专栏成为您编程旅程中的可靠伙伴。开发一个简易的文字冒险游戏,通过文本描述场景和事件,让玩家通过选择不同的选项来推动故事发展。

Python老吕的博客 713

PAT 甲级 1045  Favorite Color Stripe

1045 Favorite Color Stripe (30 point(s)) Eva is trying to make her own color stripe out of a given one. She would like to keep only her favorite colors in her favorite order by cutting off those unwa...

漫浸天空的雨色的备忘录~ 933

Vue3 - Vite运行打包时Uncaught ReferenceError: process is not defined(解决vue3+vite报错process is not defined)

vue3,vite,vue3+vite报错,process,UncaughtReferenceError:processisnotdefined,浏览器控制台报错processisnotdefined解决方法,vue3如何解决报错,vite报错怎么办,前端打包UncaughtReferenceError:processisnotdefined,npmrunbuild打包报错,vite打包时出现错误,vue3打包运行找不到process,热更新会报错UncaughtRefer

🏆 前端领域优质创作者 7738

华为od统一考试B卷【宜居星球改造计划】Java&Go 实现

XXX年,人类通过对火星的大气进行宜居改造分析,使得火星已在理论上具备人类宜居的条件,由于技术原因,无法一次性将火星大气全部改造,只能通过局部处理形式,假设将火星待改造的区域为row * column的网格每个网格有3个值,宜居区、可改造区、死亡区,使用YES、NO、NA代替,YES表示该网格已经完成大气改造,NO表示该网格未进行改造,后期可进行改造,NA表示死亡区,不作为判断是否改造完成的宜居,无法穿过 初始化下,该区域可能存在多个宜居区,并且每个宜居区能同时在每个太阳日单位向上下左右四个方向的相邻格子进

MISAYAONE的博客 1万+

PAT甲级 1045 Favorite Color Stripe(动态规划)

3.动态规划:对每一个位置的颜色进行判断,找出其作为最后一个部分的彩带最长长度。但是我这里提到的方法在AcWing会超时,后面有时间会改进。2.仅将喜欢的颜色放进处理的vector中,减少处理数量。1.喜欢的颜色不重复(感觉题设描述不太清楚)

Liu_Xingyun的博客 389

Sigrity System Explorer Transient Analysis模式进行瞬态仿真分析操作指导-单端信号

Sigrity System Explorer Transient Analysis模式可以用于瞬态仿真分析,通过搭建简易拓扑用于前仿真分析通道的时域性能,下面搭建一个简易的单端拓扑进行说明,以下图为例,准备好发送接收端的IBIS模型, (ibis_se.ibs,本例发送接收端都使用相同的IBIS模型),以及传输线的S参数模型(welement_se.sp)最上方的图形界面是传输线的模型,本例是一个上下都有参考平面的带状线,右侧的梯形是蚀刻角度,根据W1和W2以及铜厚来确定。

weixin_54787054的博客 419

1045 Favorite Color Stripe (30 point(s))

题解 LIS模板题。 #include&lt;iostream&gt; #include&lt;cstdio&gt; #include&lt;algorithm&gt; using namespace std; const int MAXN = 1e4 + 10; const int MAXM = 2e2 + 10; bool book[MAXM]; //标记那些颜色是需要的, 便于去除...

徐伯莱 309

廖雪峰Python教程[完整版]

廖雪峰的python教程整理的,已经排好版了,而且还是完整的,适合小白

Statistics and Machine Learning Toolbox

Statistics and Machine Learning Toolbox(带书签),MATLAB统计学习工具

1045 Favorite Color Stripe (30 point(s))

1045 Favorite Color Stripe (30 point(s)) Eva is trying to make her own color stripe out of a given one. She would like to keep only her favorite colors in her favorite order by cutting off those unwanted pieces and sewing the remaining parts together to fo

GitHub:https://github.com/myp020301 226

jre9下载 jdk9

(Java SE Runtime Environment 9.0) 9.0u175 官方最新版 【x86|x64】

1045 Favorite Color Stripe (30point(s))

Eva is trying to make her own color stripe out of a given one. She would like to keep only her favorite colors in her favorite order by cutting off those unwanted pieces and sewing the remaining parts...

lx18303916的博客 229

visio安装包

Microsoft Office Visio 是一款专业的制图软件。利用经过更新的形状、协作工具和数据链接图表,创建专业级图表以简化复杂的信息。

PAT A1045 Favorite Color Stripe (30point(s))

Eva is trying to make her own color stripe out of a given one. She would like to keep only her favorite colors in her favorite order by cutting off those unwanted pieces and sewing the remaining parts...

qq_42347617的博客 267

PAT(甲级)1045 Favorite Color Stripe (30point(s))

题目 题目链接 思路 题目大意:给一些喜欢的颜色,注意这些颜色是有优先级的;再给一个颜色数组,从这个颜色数组中找到最长的子序列,要求这个子序列中的颜色都是喜欢的颜色,且顺序与给的颜色优先级顺序一致(但不要求每个喜欢的颜色都被选择); 这道题的巧妙之处在于转化为了一个求最长不下降子序列长度问题,因为喜欢的颜色是有优先级的,所以可以从0到n标号,代表优先级;然后把给的颜色序列中不喜欢额颜色剔除,只剩下喜欢的,且喜欢的颜色用其优先级表示;这样就转化为了求最长不下降子序列长度问题; 状态划分和转移:dp[i] 代表

hjyp的博客 235

1045 Favorite Color Stripe (30 point(s)) - C语言 PAT 甲级

设计思路: 仅需要输出子序列最长的长度,可按照递增子序列记录长度;

有三只土豆 193

PAT甲级练习1045 Favorite Color Stripe (30 point(s)) dp解LIS

PAT甲级1045 题目 题意 第一行给定一个n表示总颜色数,颜色种类用1 ~ n数字表示 第二行第一个数是Eva喜欢的颜色数m,后面m个数代表Eva喜欢的颜色序列 第三行第一个数是彩带的长度L,后面L个数代表彩带上的颜色序列 我们要做的就是找出在彩带上符合Eva喜欢的颜色序列(符合顺序即可,可以缺少)的最大长度,例如Eva喜欢的颜色序列是{2, 3, 1, 5, 6},彩带序列是{2, 2, 4, 1, 5, 5, 6, 3, 1, 1, 5, 6},输出就是7 思路(LIS) 为了符合LIS的思路,我

RainGiving的博客 299

A1045 Favorite Color Stripe (30 分)(最长不下降子序列问题)(DP)

Eva is trying to make her own color stripe out of a given one. She would like to keep only her favorite colors in her favorite order by cutting off those unwanted pieces and sewing the remaining parts...

julia7_的博客 288

1045 Favorite Color Stripe (30)(30 point(s) 可重复LCS

1045 Favorite Color Stripe (30)(30 point(s)) Eva is trying to make her own color stripe out of a given one. She would like to keep only her favorite colors in her favorite order by cutting off those ...

Cute_jinx的博客 334

1045. Favorite Color Stripe (30) LIS

1045. Favorite Color Stripe (30) 时间限制 200 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue Eva is trying to make her own color

zhangchaosd的博客 276

PAT甲级-1045 Favorite Color Stripe (30分)

题目:1045 Favorite Color Stripe (30分) 分析:DP-----本题可用两种DP来解决,本题中要注意不是favorite的颜色不要加入DP,即num的计算。 1、最长不下降子序列(LIS) dp[i]=max(1,dp[j] + 1)//dp[i]表示以a[i]结尾的最长的长度 #include <iostream> #include<cstring> #include<vector> #include<stdio.h> #i.

WanDerIngcc的博客 221

1045 Favorite Color Stripe

【代码】1045 Favorite Color Stripe。

weixin_51735301的博客 366

【PAT甲级】1045 Favorite Color Stripe (30 分)(DP)

题意: 输入一个正整数N(<=200),代表颜色总数,接下来输入一个正整数M(<=200),代表喜爱的颜色数量,接着输入M个正整数表示喜爱颜色的编号(同一颜色不会出现两次),接下来输入一个正整数L(<=10000),代表条带的长度,接着输入L个正整数表示条带上的颜色的编号。输出以喜爱颜色顺序排列的最长子串长度(不必每种颜色都有,只保证相对位置相同,同种颜色可连续...

weixin_30919571的博客 419
上一篇: 1040 Longest Symmetric String (25 point(s))
下一篇: 1062 Talent and Virtue (25 point(s))
coderwait
博客等级 码龄9年 20粉丝 210原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值