ICode9

精准搜索请尝试: 精确搜索
  • 659. Split Array into Consecutive Subsequences2022-08-19 13:33:05

    You are given an integer array nums that is sorted in non-decreasing order. Determine if it is possible to split nums into one or more subsequences such that both of the following conditions are true: Each subsequence is a consecutive increasing se

  • [LeetCode] 792. Number of Matching Subsequences2022-07-20 13:32:12

    Given a string s and an array of strings words, return the number of words[i] that is a subsequence of s. A subsequence of a string is a new string generated from the original string with some characters (can be none) deleted without changing the rel

  • CF597C Subsequences 题解2022-06-18 12:31:09

    题意 略。 分析 一眼望去发现是 dp。容易想到状态 \(dp_{i,j}\) 表示以第 \(i\) 位为结尾长度为 \(j\) 的严格上升子序列个数,转移方程为: \[dp_{i,j}=\sum\limits_{a_k<a_i \and k<i} dp_{k,j-1} \]但是这样做的时间复杂度为 \(\mathcal{O}(n^2m)\),显然会 TLE,因此考虑优化: 可以想到

  • 洛谷P3131 Subsequences Summing to Sevens S2021-11-13 10:00:07

    洛谷P3131 Subsequences Summing to Sevens S 题目大意 给你\(n\)个数,分别是\(a[1],a[2],...,a[n]\)。求一个最长的区间\([x,y]\),使得区间中的数\(a[x],a[x+1],a[x+2],...,a[y-1],a[y]\)的和能被7整除。输出区间长度。若没有符合要求的区间,输出0。 分析 由题目最先想到使用前缀和

  • 题解 CF1409F Subsequences of Length Two2021-11-05 19:31:59

    转眼间已经快一个月没有写博客了呢 我的 dp 水平似乎都留在了 CSP 考场上那个惊险的 dp 上,最近试了几道 dp 都没做出( 最多修改 \(k\) 次,求字符串 \(\textsf{ab}\) 在子序列 \(s\) 中出现的最多次数。 原来的想法是 \(f(i, j, k)\) 表示前 \(i\) 个用了 \(j\) 次修改,有第 \(i\)

  • cf102012D. Rikka with Subsequences2021-10-30 23:05:31

    题目描述 题解 好难啊呜呜,怎么想的到。 三次方,那就相当于枚举可重复的三个相同的子序列的答案。 于是我们记 $f_{i,j,k}$ 表示第一个子序列最后一位为原序列中的第 $i$ 个,第二个子序列为 $j$ ,第三个为 $k$ 的方案数。因此只有当 $a_i=a_j=a_k$ 才有值。 转移为 $f_{i,j,k}=\Sigma

  • 【第一道水题】A. Two Subsequences2021-10-26 18:32:50

    题目来源:Problem - A - CodeforcesCodeforces. Programming competitions and contests, programming communityhttps://codeforces.com/contest/1602/problem/A 题干:  第一道水题,结果被想复杂了。这个只需要将字符串进行排序,然后输出一个最小元素和一个缺少最小元素的字串即

  • CF1529-B. Sifid and Strange Subsequences2021-10-01 18:32:34

    题意 题目定义了奇怪数组: ​ 对于数组中任意的两个元素\(a_i\)、\(a_j\),如果\(|a_i-a_j|\ge max\{a_1, a_2,...,a_k\}\),就称这个数组为奇怪数组。 现在给你一个长度为\(n\)的数组\(a\),让你找出\(a\)的一个最长子序列,并且这个子序列为奇怪数组。 思路 可以得到的两个很明显的结论

  • P3131 [USACO16JAN]Subsequences Summing to Sevens S2021-07-11 07:00:40

    Problem 给一个长度为\(n\)的序列,求最长连续子序列,满足子序列和是7的倍数。\(n \le 50000\)。 Solution 不难发现先将每个\(a_i \bmod 7\),随后前缀和,令\(q_i = \sum_{j = 1}^i a_j\)。再将\(q_i \bmod 7\)。题目转变为求一个二元组\((i,j)\),使得\(q_j - q{i - 1}\)是0且\(j - i +

  • Codeforces 950C-Zebras(模拟构造)2021-06-05 18:57:50

    题目链接:https://codeforces.com/problemset/problem/950/C 博客园食用链接:https://www.cnblogs.com/lonely-wind-/p/13453216.html Oleg writes down the history of the days he lived. For each day he decides if it was good or bad. Oleg calls a non-empty sequence of da

  • E. Subsequences (easy version)(bfs贪心)2021-05-23 14:00:04

    https://codeforces.com/problemset/problem/1183/E 思路:easy版本用贪心即可。一层层找。k总共只有100个 #include<iostream> #include<vector> #include<queue> #include<cstring> #include<cmath> #include<map> #include<set> #include<cstdio&

  • 【题解】CF1227D Optimal Subsequences2021-04-05 10:33:49

    题意 给定一个长度为 $n$ 的序列 $a_1,a_2,...,a_n$。 有 $m$ 个询问,每个询问给出两个正整数 $k,pos$。你需要找到一个长度为 $k$ 的子序列,且满足如下要求: 该子序列的元素和是所有子序列中最大的; 该子序列是所有满足上一条件的子序列中字典序最小的一个。 对于每个询问,输出该子

  • 1332. Remove Palindromic Subsequences (E)2021-03-08 19:01:55

    Remove Palindromic Subsequences (E) 题目 Given a string s consisting only of letters 'a' and 'b'. In a single step you can remove one palindromic subsequence from s. Return the minimum number of steps to make the given string empty. A st

  • CodeForces 803F :Coprime Subsequences 思维2021-01-22 13:31:13

    传送门 题目描述 现在给定一个数列 a 包含 n 个正整数,问这个数列包含几个不同的不可约子序列。由于答案会很大,所以对 109 + 7 取模。 我们称序列 a1, a2… ak 是不可约的当且仅当gcd(a1,a2…,ak)等于 1。 分析 我们去算每一个数作为最小值的时候他的倍数有多少,然后去总数2

  • 1332.remove-palindromic-subsequences2021-01-17 16:02:06

    1332. 删除回文子序列 题目描述 字符串s仅由a和b构成,每一次删除操作可以从s中删除一个回文子串,问删空需要删除几次? 官方思路 这是一道脑筋急转弯题目。。。 由于只有 a 和 b 两个字符。其实最多的消除次数就是 2。因为我们无论如何都可以先消除全部的 1 再消除全部的 2(先消除

  • Solution -「CF 1132G」Greedy Subsequences2020-12-07 17:04:10

    \(\mathcal{Description}\)   Link.   定义 \(\{a\}\) 最长贪心严格上升子序列(LGIS) \(\{b\}\) 为满足以下两点的最长序列: \(\{b\}\) 是 \(\{a\}\) 的子序列。 \(\{b\}\) 中任意相邻两项对应 \(\{a\}\) 中 \(a_i,a_j\),则 \(a_i<a_j\) 且不存在 \(i<k<j\),s.t. \(a_i<a_k\

  • [LeetCode] 659. Split Array into Consecutive Subsequences2020-12-04 12:04:07

    Given an array nums sorted in ascending order, return true if and only if you can split it into 1 or more subsequences such that each subsequence consists of consecutive integers and has length at least 3. Example 1: Input: [1,2,3,3,4,5] Output: True Exp

  • Codeforces 1426F - Number of Subsequences (dp)2020-10-01 19:34:30

    Codeforces Round #674 (Div. 3) F - Number of Subsequences 题意 给定一个长度为\(n\)字符串,仅包含\(\{a,b,c,?\}\)这四种字符。 字符\(?\)为通配符,可以匹配\(\{a,b,c\}\)三种字符中的任意一种。如果字符串内含有\(k\)个通配符,则最终可以得到\(3^k\)个不同字符串。 问在这\(3^k

  • [LeetCode] 491. Increasing Subsequences2020-09-27 04:32:31

    Given an integer array, your task is to find all the different possible increasing subsequences of the given array, and the length of an increasing subsequence should be at least 2. Example: Input: [4, 6, 7, 7] Output: [[4, 6], [4, 7], [4, 6, 7], [4, 6,

  • CF1409F Subsequences of Length Two2020-09-19 10:00:21

    水题大师( 题意:给定两个字符串,给定m次修改机会,求第二个串作为第一个串子序列的最大数量。其中第二个串是长度为2的字符串。 将对标串是两个相同字母的特殊情况先处理;n的范围是200,考虑三维dp 记第二个串为s2,下标从1开始;计算子序列的数量可以通过 当 s1[i]==s2[2]时 sum+=k ,k代表前i

  • 问题 E: Mountain Subsequences2020-09-12 11:31:20

    问题 E: Mountain Subsequences 时间限制: 1 Sec  内存限制: 128 MB提交 状态 题目描述 Coco is a beautiful ACMer girl living in a very beautiful mountain. There are many trees and flowers on the mountain, and there are many animals and birds also. Coco

  • D. Binary String To Subsequences(队列)(贪心)2020-08-06 08:31:39

    题意:你被给予了一个二进制字符串包含n个零和n个一。你的任务是分割这个字符串为最小的数量的子串,使得这些子串为'010101...'或者'101010...',输出每个字符属于的字符串编号。 分析:一开始想的是,字符个数为o(n),应该是一个线性的时间复杂度或者是o(nlogn)的时间复杂度,如果当前字符是

  • Codeforces - Friends and Subsequences2020-02-03 14:40:17

    题目链接:Codeforces - Friends and Subsequences 很显然max和min的前缀和具有单调性。 所以我们枚举左端点,二分右端点即可。 AC代码: #pragma GCC optimize("-Ofast","-funroll-all-loops") #include<bits/stdc++.h> //#define int long long using namespace std; const in

  • [Leetcode]659.Split Array into Consecutive Subsequences2020-01-31 16:06:57

    链接:LeetCode659 输入一个按升序排序的整数数组(可能包含重复数字),你需要将它们分割成几个子序列,其中每个子序列至少包含三个连续整数。返回你是否能做出这样的分割? 示例 1: 输入: \([1,2,3,3,4,5]\) 输出: True 解释: 你可以分割出这样两个连续子序列 : 1, 2, 3 3, 4, 5 相关标签:贪

  • CF1261B1 Optimal Subsequences (Easy Version)2019-12-08 15:56:16

    题意:求字符串中取k长度的子序列使总数最大,并且字典序最小 题解:首先易知子序列总数最大肯定要在字符串中取出k个最大的数组成子序列,只需要将字符串排序后把最大的k个数存入一个数组,但是本题难点在于要求字典序最小的子序列,比如 10 20 20 是答案而 20 10 20不是答案 即使他们的总数

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有