CF261D.Maxim and Increasing Subsequence
省选/NOI-
通过率:0%
时间限制:6.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Maxim loves sequences, especially those that strictly increase. He is wondering, what is the length of the longest increasing subsequence of the given sequence a?
Sequence a is given as follows:
- the length of the sequence equals n × t;
(1 ≤ i ≤ n × t), where operation
means taking the remainder after dividing number x by number y.
Sequence _s_1, _s_2, ..., s__r of length r is a subsequence of sequence _a_1, _a_2, ..., a__n, if there is such increasing sequence of indexes _i_1, _i_2, ..., i__r (1 ≤ _i_1 < _i_2 < ... < i__r ≤ n), that a__i__j = s__j. In other words, the subsequence can be obtained from the sequence by crossing out some elements.
Sequence _s_1, _s_2, ..., s__r is increasing, if the following inequality holds: _s_1 < _s_2 < ... < s__r.
Maxim have k variants of the sequence a. Help Maxim to determine for each sequence the length of the longest increasing subsequence.
马克西姆热爱序列,尤其是严格递增的序列。他想知道:给定序列 a 的最长递增子序列(LIS)的长度是多少?
序列 a 的定义如下:
- 序列的长度为 n×t;
- ai=b(i−1)modn+1(其中 1≤i≤n×t),其中运算 xmody 表示 x 除以 y 后的余数。
长度为 r 的序列 s1, s2, …, sr 是序列 a1, a2, …, an 的一个子序列,当且仅当存在一个严格递增的下标序列 i1, i2, …, ir(满足 1≤i1<i2<⋯<ir≤n),使得对所有 j=1,2,…,r 都有 aij=sj。换言之,该子序列可通过从原序列中删去若干元素得到。
序列 s1, s2, …, sr 是递增的,当且仅当满足如下不等式:s1<s2<⋯<sr。
马克西姆共有 k 个不同的序列 a。请帮助他分别求出每个序列的最长递增子序列的长度。
输入格式
The first line contains four integers k, n, maxb and t (1 ≤ k ≤ 10; 1 ≤ n, maxb ≤ 105; 1 ≤ t ≤ 109; n × maxb ≤ 2·107). Each of the next k lines contain n integers _b_1, _b_2, ..., b__n (1 ≤ b__i ≤ maxb).
Note that for each variant of the sequence a the values n, maxb and t coincide, the only arrays _b_s differ.
The numbers in the lines are separated by single spaces.
第一行包含四个整数 k、n、maxb 和 t(1 ≤ k ≤ 10;1 ≤ n,maxb ≤ 105;1 ≤ t ≤ 109;n × maxb ≤ 2⋅107)。接下来的 k 行中,每行包含 n 个整数 b1,b2,...,bn(1 ≤ bi ≤ maxb)。
注意:对于每个序列 a 的变体,参数 n、maxb 和 t 均相同,仅数组 b 不同。
各行中的数字以单个空格分隔。
输出格式
Print k integers — the answers for the variants of the sequence a. Print the answers in the order the variants follow in the input.
输出 k 个整数——即序列 a 的各变体所对应的答案。请按照输入中各变体出现的顺序输出答案。
输入输出样例
输入#1
3 3 5 2 3 2 1 1 2 3 2 3 1
输出#1
2 3 3
输入解题思路,AI测评打分。不知道怎么写?