| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 414 人关注过本帖
标题:还有一题,很有趣。。用c程序怎么编写啊??
只看楼主 加入收藏
katherine2o1
Rank: 1
等 级:新手上路
帖 子:6
专家分:0
注 册:2011-4-3
结帖率:100%
收藏
 问题点数:0 回复次数:0 
还有一题,很有趣。。用c程序怎么编写啊??
For a sequence S1,S2,...,SN, and a pair of integers (i, j), if 1 <= i <= j <= N and Si < Si+1 < Si+2 <...< Sj-1 < Sj, then the sequence Si,Si+1,...,Sj is a CIS (Continuous Increasing Subsequence). The longest CIS of a sequence is called the LCIS (Longest Continuous Increasing Subsequence).

In this problem, we will give you a sequence first, and then some “add” operations and some “query” operations. An add operation adds a value to each member in a specified interval. For a query operation, you should output the length of the LCIS of a specified interval.

 

Input
The first line of the input is an integer T, which stands for the number of test cases you need to solve.

Every test case begins with two integers N, Q, where N is the size of the sequence, and Q is the number of queries. S1,S2,...,SN are specified on the next line, and then Q queries follow. Every query begins with a character ‘a’ or ‘q’. ‘a’ is followed by three integers L, R, V, meaning that add V to members in the interval [L, R] (including L, R), and ‘q’ is followed by two integers L, R, meaning that you should output the length of the LCIS of interval [L, R].


T <= 10;


1 <= N, Q <= 100000;


1 <= L <= R <= N;


-10000 <= S1,S2,...,SN, V <= 10000.



 

Output
For every test case, you should output "Case #k:" on a single line first, where k indicates the case number and starts at 1. Then for every ‘q’ query, output the answer on a single line. See sample for more details.
 

Sample Input
1
5 6
0 1 2 3 4
q 1 4
a 1 2 -10
a 1 1 -6
a 5 5 -4
q 2 3
q 4 4

 

Sample Output
Case #1:
4
2
1

搜索更多相关主题的帖子: operation specified sequence problem 
2011-04-03 15:50
快速回复:还有一题,很有趣。。用c程序怎么编写啊??
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.015289 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved