cf446A DZY Loves Sequences】的更多相关文章

A. DZY Loves Sequences time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output DZY has a sequence a, consisting of n integers. We'll call a sequence ai, ai + 1, ..., aj (1 ≤ i ≤ j ≤ n) a subsegment…
DZY has a sequence a, consisting of n integers. We'll call a sequence ai, ai + 1, ..., aj (1 ≤ i ≤ j ≤ n) a subsegment of the sequence a. The value (j - i + 1) denotes the length of the subsegment. Your task is to find the longest subsegment of a, su…
题目地址:http://codeforces.com/contest/447/problem/C C. DZY Loves Sequences time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output DZY has a sequence a, consisting of n integers. We'll call a sequence…
C. DZY Loves Sequences time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output DZY has a sequence a, consisting of n integers. We'll call a sequence ai, ai + 1, ..., aj (1 ≤ i ≤ j ≤ n) a subsegment…
预处理出每一个数字能够向后延伸多少,然后尝试将两段拼起来. C. DZY Loves Sequences time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output DZY has a sequence a, consisting of n integers. We'll call a sequence ai, ai + 1, ..., a…
C - DZY Loves Sequences DZY has a sequence a, consisting of n integers. We'll call a sequence ai, ai + 1, ..., aj (1 ≤ i ≤ j ≤ n) a subsegment of the sequence a. The value (j - i + 1) denotes the length of the subsegment. Your task is to find the lon…
447C - DZY Loves Sequences 思路:dp 代码: #include<bits/stdc++.h> using namespace std; #define ll long long const int INF=0x3f3f3f3f; ; int a[N]; int f[N],g[N]; int main() { ios::sync_with_stdio(false); cin.tie(); int n; cin>>n; f[]=; cin>>a[…
A. DZY Loves Sequences 题目连接: http://www.codeforces.com/contest/446/problem/A Description DZY has a sequence a, consisting of n integers. We'll call a sequence ai, ai + 1, ..., aj (1 ≤ i ≤ j ≤ n) a subsegment of the sequence a. The value (j - i + 1) d…
题目传送门 /* DP:先用l,r数组记录前缀后缀上升长度,最大值会在三种情况中产生: 1. a[i-1] + 1 < a[i+1],可以改a[i],那么值为l[i-1] + r[i+1] + 1 2. l[i-1] + 1 3. r[i+1] + 1 //修改a[i] */ #include <cstdio> #include <algorithm> #include <cstring> using namespace std; ; const int INF…
C. DZY Loves Sequences time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output DZY has a sequence a, consisting of n integers. We'll call a sequence ai, ai + 1, ..., aj (1 ≤ i ≤ j ≤ n) a subsegment…
time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output DZY has a sequence a, consisting of n integers. We'll call a sequence ai, ai + 1, ..., aj (1 ≤ i ≤ j ≤ n) a subsegment of the sequence a. The…
vjudge 上题目链接:codeforces 446A 大意是说最多可以修改数列中的一个数,求最长严格递增的连续子序列长度. 其实就是个 dp 的思想,想好思路后交上去没想到一直 wa 在第二个测试数据里,丧心病狂啊 T.T,后来才知道原来是分类讨论时没考虑全,而且下标也写拙了. 情况有三: (1) 不作任何修改,直接遍历一遍求出的 in 数组和 de 数组即可.(其实这种情况不会优于(3),可以不用考虑) (2) 修改的元素为最长递增子序列的中间结点,把左边的 in[i - 1] 加上右边的…
解题报告:输入一个数列,选取一个子数列,要求最多只能改动这个子数列中的一个数,使得这个子数列是严格的升序的(严格升序没有相等的) 我的做法是,第一步把这个 数列的每个升序的子数列都找出来,然后看这些子数列能不能和跟它相邻的升序的子数列连接起来. #include<cstdio> #include<cstring> #include<iostream> #include<algorithm> #include<cmath> using namesp…
题目链接: http://www.codeforces.com/contest/446/problem/A 题解: dp1[x]表示以x结尾的最大严格升序连续串,dp2[x]表示以x开头的最大严格升序连续串 #include<iostream> #include<cstdio> #include<cstring> #include<map> #include<list> #include<stack> #include<algo…
题意:给出一列数,在这个序列里面找到一个连续的严格上升的子串,现在可以任意修改序列里面的一个数,问得到的子串最长是多少 看的题解,自己没有想出来 假设修改的是a[i],那么有三种情况, 1.a[i]>a[i-1],那么求出向左能够延伸的最长的长度 2.a[i]<a[i-1],那么求出向右能够延伸的最长的长度 3.如果修改的这个数刚好夹在两个数的中间,这种情况比上面两种都优, 即为a[i-1]<a[i+1]-1,求出左右能够延伸的最长的长度 然后因为a[i]本身还没有算进去,所以求出最大值…
http://codeforces.com/contest/447/problem/C 题意:给你n个数的序列,然后让你改变其中的一个数,求得最长上升连续序列的长度值. 思路:先从左边开始求出连续递增序列的值记录在l数组,然后从右边开始再求一遍连续递增序列的值记录在r数组中,然后从2-n-1位置遍历,改变其中的一个数,使得组成一个新的递增序列,求出长度最大值就可以. #include <cstdio> #include <cmath> #include <iostream&g…
题目:click here 题意:求给定序列更改其中一个元素后的最长连续上升子序列的长度 分析:最长的连续子序列有2种,一种是严格上升(没有更改元素)的长度加1,一种是两段严格上升的加起来. #include <bits/stdc++.h> using namespace std; #define F first #define S second #define pb push_back #define power(a) ((a)*(a)) #define ENTER printf("…
<题目链接> 题目大意: 给定一个长度为$n$的序列,现在最多能够改变其中的一个数字,使其变成任意值.问你这个序列的最长严格上升子段的长度是多少. #include <bits/stdc++.h> using namespace std; ; int a[N],suf[N],pre[N]; int main(){ ;cin>>n; ;i<=n;++i) scanf(]=1e9+; ;i<=n;++i) { ]) pre[i]=pre[i-]+;; ans=m…
题目链接:http://codeforces.com/problemset/problem/447/C 题目意思:给出 一个 包含 n 个数的序列你,从中需要找出这个序列的最长子串,满足在里面只修改其中一个元素,使得这个子串的元素严格递增,求出这个长度是多少. 以为是DP题(它的分类确实是DP题),无从下手.看了下别人写的,有些部分不太明白:根据自己的理解再结合一些别人的,加了些特判,总算过了^_^,我好像觉得我的做法不像是用了DP思想咯........ 总体思路就是:设两个数组,分别为inc_…
题意:给定一个序列,让你找出一个最长的序列,使得最多改其中的一个数,使其变成严格上升序列. 析:f[i] 表示以 i 结尾的最长上升长度,g[i] 表示以 i 为开始的最长上升长度,这两个很容易就求得,最后枚举中间值即可. 代码如下: #pragma comment(linker, "/STACK:1024000000,1024000000") #include <cstdio> #include <string> #include <cstdlib>…
[链接] 我是链接,点我呀:) [题意] 让你找一段连续的区间 使得这一段区间最多修改一个数字就能变成严格上升的区间. 问你这个区间的最长长度 [题解] dp[0][i]表示以i为结尾的最长严格上升长度 dp[1][i]表示以i作为开头的最长严格上升长度. 然后我们枚举那个改变的位置在什么地方就可以了. 别忘了不改变的那种情况. 可以一起做. [代码] import java.io.*; import java.util.*; public class Main { static InputRe…
题意:给定一个序列a,求最长的连续子序列b的长度,在至多修改b内一个数字(可修改为任何数字)的条件下,使得b严格递增. 分析: 1.因为至多修改一个数字,假设修改a[i], 2.若能使a[i] < a[i + 1] 且 a[i] > a[i - 1],则修改a[i]能得到的最长连续子序列长度为l[i - 1] + r[i + 1] + 1. 3.若不满足条件2,则修改a[i]能得到的最长连续子序列长度应取l[i - 1] + 1(即从a[i-1]能向左延伸的最大长度加上a[i]形成的序列)和r…
B. DZY Loves FFT time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output DZY loves Fast Fourier Transformation, and he enjoys using it. Fast Fourier Transformation is an algorithm used to calculate…
B. DZY Loves FFT 题目连接: http://codeforces.com/contest/444/problem/B Description DZY loves Fast Fourier Transformation, and he enjoys using it. Fast Fourier Transformation is an algorithm used to calculate convolution. Specifically, if a, b and c are s…
C. DZY Loves Colors time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output DZY loves colors, and he enjoys painting. On a colorful day, DZY gets a colorful ribbon, which consists of n units (they…
题目 Source http://codeforces.com/problemset/problem/444/C Description DZY loves colors, and he enjoys painting. On a colorful day, DZY gets a colorful ribbon, which consists of n units (they are numbered from 1 to n from left to right). The color of t…
A. DZY Loves Chessboard time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output DZY loves chessboard, and he enjoys playing with it. He has a chessboard of n rows and m columns. Some cells of the c…
3309: DZY Loves Math Time Limit: 20 Sec  Memory Limit: 512 MBSubmit: 761  Solved: 401[Submit][Status][Discuss] Description 对于正整数n,定义f(n)为n所含质因子的最大幂指数.例如f(1960)=f(2^3 * 5^1 * 7^2)=3, f(10007)=1, f(1)=0.给定正整数a,b,求sigma(sigma(f(gcd(i,j)))) (i=1..a, j=1.…
题目链接: 传送门 DZY Loves Chemistry time limit per test1 second     memory limit per test256 megabytes Description DZY loves Physics, and he enjoys calculating density. Almost everything has density, even a graph. We define the density of a non-directed gr…
题目链接: 传送门 DZY Loves Chemistry time limit per test:1 second     memory limit per test:256 megabytes Description DZY loves chemistry, and he enjoys mixing chemicals. DZY has n chemicals, and m pairs of them will react. He wants to pour these chemicals…