subsequence
[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 ......
[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 Addition
# Subsequence Addition (Hard Version) ## 题面翻译 本题为困难版,两题的唯一区别在于数据范围的大小。 数列 $a$ 最开始只有一个数 $1$,你可以进行若干次操作,每次操作你可以选取 $k$ 个数($k$ 无限制,小于等于 $a$ 的大小即可),将这 $k$ ......
CF280D k-Maximum Subsequence Sum
大半个月前做的题,现在才写题解,/qd/qd。 贪心,选出 $k$ 个不相交子段的和的最大值,其实相当于每次把序列最大子段拎出来,加上去,然后取相反数。 证明的话可以考虑模拟费用流,$i\le n$,$S\to i$ 连边,$i\to i+1$ 连边,$i\to T$ 连边,边的流量均为 $1$,$ ......
ABC248Ex Beautiful Subsequences
 然而这个经典做法是分治,我不太会做,但这确实是一道经典题。 考虑扫描线,对从左到右每个点 $r$,统计以 $r$ 作为右端点的区间个数。 由于 $r$ 端点固定,$S(l) ......
CF1132G Greedy Subsequences
简单题。 $i$ 向 $i$ 后**第一个** $j$,$a_j$ 比 $a_i$ 大的点连边,不难发现最后形成了一棵森林,并且一个点的父亲 $\text{fa}_i>i$。 题目变成了取 $[l,r]$ 中的点为起点,向祖先方向走去并且终点编号 $\le r$ 的最长链长度。 考虑离线,维护从每个 ......
[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, ..., NK }. A continuous subsequence is defined to be { Ni, Ni+1, ..., Nj } where 1≤i≤j≤K. The Maximum S ......
[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 ......
【CF1621G】Weighted Increasing Subsequences 题解(优化树状数组)
[CF 传送门](https://codeforc.es/contest/1621/problem/G) | [LG 传送门](https://www.luogu.com.cn/problem/CF1621G)。 优化树状数组 + 反向处理。 ## Solution - 发现直接做不好下手。难点主要 ......
CF1580D Subsequence 题解
本文网址:https://www.cnblogs.com/zsc985246/p/17509039.html ,转载请注明出处。 ## 传送门 [CF1580D Subsequence](https://codeforces.com/contest/1580/problem/D) ## 题目大意 有 ......
Scoring Subsequences
Scoring Subsequences time limit per test 2.5 seconds memory limit per test 256 megabytes input standard input output standard output The score of a se ......
「解题报告」CF1621G Weighted Increasing Subsequences
比较套路的拆贡献题。 考虑直接枚举那个 $j$,求有多少包含 $j$ 的上升子序列满足这个子序列最后一个数的后面有大于 $a_j$ 的数。 首先对于 $j$ 前面的选择方案是没有影响的,可以直接拿树状数组 DP 一遍得到。后面的过程我们可以找到从后往前第一个大于 $a_j$ 的数的位置 $x$,那么 ......
subsequence 2 (拓扑排序)
题面大意: 给定一个隐藏字符串, 每次给出2个字母所产生的子序列, 问你原序列是什么 思路: 性质: 字母和字母之间有先后顺序 因此拓扑排序建边来做 然后不要一次把边建完, 而是通过相对位置关系, 边更新,边建. (先找第一个,在找第二个....) #include<bits/stdc++.h> u ......
abc271_e Subsequence Path 题解
# [Subsequence Path](https://vjudge.csgrandeur.cn/problem/AtCoder-abc271_e) ## 题意 有 $n$ 个城市和 $m$ 条有向道路,编号从 $1$ 开始,第 $i$ 条道路从 $a_i$ 到 $b_i$,长度为 $c_i$。 ......
subsequence1 (牛客多校) (2个串比大小, DP, 组合数)
题面大意: 给定2个字符串,问有多少个子字符串S, 是大于t的 思路 数据范围很小, 因此考虑n^2做法 分2步, 位数s>位数t 的时候 然后 位数相等的时候 利用DP ,处理, 分别就是枚举 前 k个数和s相同,然后k+1个数比t大就可以. 具体思路自己想想,和那个比较像 const int M ......
「USACO2016JAN」Subsequences Summing to Sevens
[USACO16JAN]Subsequences Summing to Sevens S 题目描述 Farmer John's $N$ cows are standing in a row, as they have a tendency to do from time to time. Each ......
CF750E - New Year and Old Subsequence
题意:给一个字符串,每次询问它的一个区间,问最少删除多少个字符,使得区间没有子序列 2016,但是有子序列 2017。 My solution 首先考虑贪心,通过预处理的方式找到区间最后一个 7,依次往前贪心的找到最靠后的一组 2017。接下来,我们需要 7 的后面没有 6,7 前面的部分不能组合出 ......
PAT Advanced 1007. Maximum Subsequence Sum
PAT Advanced 1007. Maximum Subsequence Sum 1. Problem Description: Given a sequence of $K$ integers { $N_1, N_2, ..., N_K$ }. A continuous subsequence ......
AtCoder Regular Contest 134 D Concatenate Subsequences
洛谷传送门 AtCoder 传送门 我一年前甚至不会做/qd 发现 $a_{x_1}$ 为 $k = \min\limits_{i=1}^n a_i$ 时最优。然后开始分类讨论: 如果 $\min\limits_{a_i = k} a_{i+n} \le k$,答案为 $(k, \min\limit ......
[ABC299F] Square Subsequence
Problem StatementYou are given a string $S$ consisting of lowercase English letters. Print the number of non-empty strings $T$ that satisfy the follow ......
CF1814E Chain Chips & CF750E New Year and Old Subsequence - 动态 dp -
一句话概括动态 dp:用来解决带修改/多次区间询问的 dp 问题。将转移写成矩阵的形式,然后利用线段树求解区间问题/单点修改 1814E 注意一条边要么选 2 要么选 0 次,而且第一条边一定是选了 2 次。如果有一条边没选,那么这条边两侧的边一定都选了。 设 $f_i$ 代表考虑到第 $i$ 条边 ......
【题解】[ABC299F] Square Subsequence(DP)
【题解】[ABC299F] Square Subsequence 题目链接 [ABC299F] Square Subsequence 题意概述 给定一个由小写英文字母组成的字符串 $S$。计算满足以下条件的非空字符串 $T$ 的数量,答案对 $998244353$ 取模。 将 $T$ 复制一倍形成 ......
[Algorithm] Dynamic programming - 02 - Longest Common Subsequence - Drawing 2d matrix + back tracing
Write a function that takes in two strings and returns their longest common subsequence. A subsequence of a string is a set of characters that aren't ......