A8798 | Maxim and Increasing Subsequence
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
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_{ij}=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.
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_{ij}=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.
输入格式
The first line contains four integers $k$ , $n$ , $maxb$ and $t$ $(1<=k<=10; 1<=n,maxb<=10^{5}; 1<=t<=10^{9}; n×maxb<=2·10^{7})$ . 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.
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.
输出格式
Print $k$ integers — the answers for the variants of the sequence $a$ . Print the answers in the order the variants follow in the input.
输入输出样例
输入 #1
3 3 5 2 3 2 1 1 2 3 2 3 1
输出 #1
2 3 3
暂无题解
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted