Subsequence

Largest Subsequence

操作:选取词性最大的子序列,向右循环一次 问你进行多少次这样的操作能使数组有序,如果不能就输出-1 思路:首先要知道的是一个词性最大的序列整个右移过后,数组的新词性最大的序列就是之前的词性最大序列去了最后一个字母. 找出词性最大的子序列 int n; string s; cin>>n>>s; for ......
Subsequence Largest

[ARC150F] Constant Sum Subsequence

更好的阅读体验 [ARC150F] Constant Sum Subsequence 很有意思的题。 设 \(nex_{i,j}\) 表示位置 \(i\) 后面的最小的满足 \(k>i\wedge a_k=j\) 的 \(k\),则问题可以抽象为: \[f_i=\max_{j=1}^inex_{f_ ......
Subsequence Constant 150F ARC 150

[ABC271E] Subsequence Path 题解

[ABC271E] Subsequence Path 题解 思路解析 很好的一道题,很有迷惑性,表面上是一道图论实际上是 dp,定义 \(f_{i}\) 为从 \(1\) 到 \(i\) 的最短 “好路”。先把每条边对应的起点,终点和边权记录下来,然后输入每个 \(e\),由于是子序列顺序不会改变, ......
题解 Subsequence 271E Path ABC

[Codeforces] CF1817A Almost Increasing Subsequence

CF1817A Almost Increasing Subsequence 题意 给定长度为 \(n\) 一个序列 \(a\) 以及 \(q\) 次询问,每次询问给出 \(l\) 和 \(r\),找出序列 \(a\) 在 \([l,r]\) 内最长的几乎递增子序列。 对于几乎递增的定义:如果一个序列 ......

[ARC133B] Dividing Subsequence

Dividing Subsequence 这道题与最长公共子序列类似,可以先去水一水那道题。 题意 本题就是让你从 \(p\) 里面选出一个子序列 \(b_i\) 和 \(q\) 里面选出一个子序列 \(a_i\),我们要使 \(b_i\) 是 \(a_i\) 的倍数。 解法 本题直接用动态规划,是 ......
Subsequence Dividing 133B ARC 133

D2. Xor-Subsequence (hard version)

D2. Xor-Subsequence (hard version) It is the hard version of the problem. The only difference is that in this version $a_i \le 10^9$. You are given an ......
Xor-Subsequence Subsequence version hard Xor

D1. Xor-Subsequence (easy version)

D1. Xor-Subsequence (easy version) It is the easy version of the problem. The only difference is that in this version $a_i \le 200$. You are given an ......
Xor-Subsequence Subsequence version easy Xor

[USACO22OPEN] Up Down Subsequence P

[USACO22OPEN] Up Down Subsequence P 注意到这个问题是不弱于直接求 LIS 的,因此考虑 dp。 设 \(f_i\) 表示以 \(i\) 结尾的最长这个什么串的长度,显然没办法直接转移,那么暴力的想法就是多设一维,这样自然就寄了。我们考虑到这样一件事情:如果我们假装 ......
Subsequence USACO OPEN Down 22

【动态规划】【动态 DP】 CF750E New Year and Old Subsequence

题目描述 定义数字串是好的当且仅当其包含子序列 2017 ,不包含子序列 2016。 定义数字串的丑陋值为最少删掉几个字符,它才能是好的,如果一直不能,就是 \(-1\) 。 给定数字串 \(t\) ,长度为 \(n\) ,\(q\) 次询问求 \([l,r]\) 的丑陋值。 \(1 \leq n, ......
动态 Subsequence 750E Year 750

PAT 甲级【1007 Maximum Subsequence Sum】

本题是考察动态规划与java的快速输入: max[i]表示第i个结尾的最大的连续子串和。b begin[i]表示第[begin[i],i]为最大和的开始位置 超时代码: import java.io.BufferedReader; import java.io.IOException; import ......
甲级 Subsequence Maximum 1007 PAT

CF568E Longest Increasing Subsequence 题解

Longest Increasing Subsequence LIS 问题有两种主流 \(O(n\log n)\) 解法,最常见的树状数组法,以及不那么常见的二分法。然后考虑本题,发现一个神奇的思路就是求出 LIS 后倒序复原出数组。 进一步思考后发现,因为本题是 LIS(Longest Incre ......
题解 Subsequence Increasing Longest 568E

CF1817A Almost Increasing Subsequence

CF1817A 题面翻译 给定长度为 \(n\) 一个序列 \(a\) 以及 \(q\) 次询问,每次询问给出 \(l\) 和 \(r\),找出序列 \(a\) 在 \([l,r]\) 内最长的几乎递增子序列。 对于几乎递增的定义:如果一个序列中不存在连续的三个数 \(x\),\(y\),\(z\) ......
Subsequence Increasing Almost 1817A 1817

Codeforces Round 685 (Div. 2) B. Non-Substring Subsequence

对于一个长为 \(n\) 的 \(01\) 字符串 \(s\) 有 \(n\) 个询问。第 \(i\) 个询问被 \(l_i, r_i\) 描述 \(1 \leq l_i < r_i \leq n\) 。 对于每个询问,你需要确定 \(s\) 中是否存在一个子序列等同于子串 \(s[l_i \cdo ......

CF261D Maxim and Increasing Subsequence 题解

Maxim and Increasing Subsequence 首先,我们可以发现,当这个重复次数很大的时候,答案就等于序列中出现的不同权值个数。实际上,这个“很大”就可以被当作“大于等于不同权值个数”。 不同权值个数实际上是 \(\min(n,m)\) 级别的,其中 \(n\) 是序列长度,\( ......
题解 Subsequence Increasing Maxim 261D

洛谷P3607 [USACO17JAN] Subsequence Reversal P 题解

Subsequence Reversal P 思路: 发现,翻转一个子序列,就意味着两两互换子序列里面的东西。 于是我们就可以设 \(f[l][r][L][R]\) 表示: \(\max[1,l)=L,\min(r,n]=R\) 时的最长长度。 则边界为: \(L>R\) 时, \(f=-\inft ......
题解 Subsequence Reversal P3607 USACO

[CF1580D]Subsequence

D - Subsequence 发现\(f(i,j)\)不好处理,考虑将其转换成另一个函数 考虑笛卡尔树,\(\min(a_i,a_{i+1},...,a_j)\)就是在笛卡尔树上,\(i\)和\(j\)的\(lca\) 那么就可以将问题转移到笛卡尔树上,设\(dp[x][c]\)表示以\(x\)所 ......
Subsequence 1580D 1580 CF

[CF568E] Longest Increasing Subsequence

题目描述 Note that the memory limit in this problem is less than usual. Let's consider an array consisting of positive integers, some positions of which c ......
Subsequence Increasing Longest 568E 568

Xor-Subsequence (字典树优化DP)

思路 ; 明显的是, 后一个 i 要从前面一个进行更新, 利用dp easy版本 ai <=200, 发现当 n>=300 时, 对他是没有影响的, 这样比较好记录 ans进行更新, 利用数据结构处理 hard 版本 拆位, 利用字典树dp , 把参数变成相同的参数, a[i] 和 i , (比大小 ......
Xor-Subsequence Subsequence 字典 Xor DP

Binary Subsequence

Description 对于所有长度为 \(n\) 的 \(2^n\) 个 01 串,对每个求出形如 000...111 的最长的子序列的长度,求出长度和。 Solution 记 \(a_i\) 表示前 \(i\) 个数中 \(0\) 的个数,\(b_i\)表 示 \(i\) 及其以后 \(1\) ......
Subsequence Binary

abc271e Subsequence Path

E - Subsequence Path 第一眼看过去感觉又是什么魔改BFS的样子,但是感觉不好弄 但是往dp上想就很容易 \(f[i]\)表示走到i的最小代价,按着给出的序列顺序转移即可,转移是O(1)的。 代码非常简单 #include<cstdio> #include<algorithm> # ......
Subsequence 271e Path abc 271

[LeetCode][300]longest-increasing-subsequence

# Content Given an integer array nums, return the length of the longest strictly increasing subsequence. Example 1: Input: nums = [10,9,2,5,3,7,101,18 ......

[ARC125D] Unique Subsequence

设 $pre_i$ 表示在 $i$ 之前最后一个和 $i$ 相同的数的位置,$dp_i$ 表示第 $i$ 个数为结尾的序列的合法方案数。 对于 $pre_i = 0$,即在 $i$ 之前不存在与 $i$ 相同的数,$dp_i$ 由 $\left[ 1,i - 1 \right]$ 转移过来。由于这个 ......
Subsequence Unique 125D ARC 125

[AGC024F] Simple Subsequence Problem

Problem StatementYou are given a set $S$ of strings consisting of 0 and 1, and an integer $K$. Find the longest string that is a subsequence of $K$ or ......
Subsequence Problem Simple 024F AGC

[ARC150F] Constant Sum Subsequence

Problem StatementWe have a sequence of positive integers of length $N^2$, $A=(A_1,\ A_2,\ \dots,\ A_{N^2})$, and a positive integer $S$. For this sequ ......
Subsequence Constant 150F ARC 150

Subsequence Addition

# Subsequence Addition (Hard Version) ## 题面翻译 本题为困难版,两题的唯一区别在于数据范围的大小。 数列 $a$ 最开始只有一个数 $1$,你可以进行若干次操作,每次操作你可以选取 $k$ 个数($k$ 无限制,小于等于 $a$ 的大小即可),将这 $k$ ......
Subsequence Addition

CF280D k-Maximum Subsequence Sum

大半个月前做的题,现在才写题解,/qd/qd。 贪心,选出 $k$ 个不相交子段的和的最大值,其实相当于每次把序列最大子段拎出来,加上去,然后取相反数。 证明的话可以考虑模拟费用流,$i\le n$,$S\to i$ 连边,$i\to i+1$ 连边,$i\to T$ 连边,边的流量均为 $1$,$ ......
Subsequence k-Maximum Maximum 280D 280

[LeetCode] 2486. Append Characters to String to Make Subsequence

You are given two strings s and t consisting of only lowercase English letters. Return the minimum number of characters that need to be appended to th ......

[LeetCode] 1218. Longest Arithmetic Subsequence of Given Difference

Given an integer array arr and an integer difference, return the length of the longest subsequence in arr which is an arithmetic sequence such that th ......

PAT-甲级-1007 Maximum Subsequence Sum C++

Given a sequence of K integers { N1​, N2​, ..., N​K }. A continuous subsequence is defined to be { Ni​, Ni+1​, ..., Nj​ } where 1≤i≤j≤K. The Maximum S ......
甲级 Subsequence Maximum 1007 PAT

[LeetCode] 2542. Maximum Subsequence Score

You are given two 0-indexed integer arrays nums1 and nums2 of equal length n and a positive integer k. You must choose a subsequence of indices from n ......
Subsequence LeetCode Maximum Score 2542
共40篇  :1/2页 首页上一页1下一页尾页