HBC52816KeepCalmAndCarryOffPair-Pair题解

天涯离梦残月幽梦 算法基础篇 40 0
全网最全C++题库,助您快速提升编程技能!题库丰富多样,涵盖各个领域,让您在练习中不断成长!
Bobo is tired of all kinds of hard LIS problems,so he decides to make himself some easier one.He defines f be the length of longest increasing subsequence of sequence. Bobo would like to know g which is the number of pairs where f = k.

Bobo is tired of all kinds of hard LIS (Longest Increasing Subsequence) problems, so he decides to make himself some easier one. Bobo has n pairs (a_1, b_1), (a_2, b_2), dots, (a_n, b_n) (a 1 ​ ,b 1 ​ ),(a 2 ​ ,b 2 ​ ),…,(a n ​ ,b n ​ ) where 1 leq a_i, b_i leq m 1≤a i ​ ,b i ​ ≤m holds for all i. He defines f(i, j) be the length of longest increasing subsequence of sequence {a_i, b_i, a_j, b_j} {a i ​ ,b i ​ ,a j ​ ,b j ​ }. It's clear that 1 leq f(i, j) leq 4 1≤f(i,j)≤4. Bobo would like to know g(k) which is the number of pairs (i, j) where f(i, j) = k. Note that a sequence labeled with {i_1, i_2, dots, i_k} {i 1 ​ ,i 2 ​ ,…,i k ​ } is an increasing subsequence of {a_1, a_2, dots, a_n} {a 1 ​ ,a 2 ​ ,…,a n ​ } only if: * 1 leq i_1 < i_2 < dots < i_k leq n 1≤i 1 ​

HBC52816KeepCalmAndCarryOffPair-Pair题解
-第1张图片-东莞河马信息技术
(图片来源网络,侵删)
不断学习,不断挑战,才能在编程领域中脱颖而出!全网最全C++题库,助您成为编程高手!

标签: HBC52816KeepCalmAndCarryOffPair-Pair题解