题目大意:给定一个长度为 N 的序列,求有多少个三元组满足 \(i<j<k,a_i<a_j<a_k\). 题解:这是一类二维偏序问题,与逆序对问题类似. 对于序列中每个点来说,用树状数组统计左边有多少个值比他小,右边有多少个值比他大,最后扫一遍数组计算答案贡献即可. 代码如下 #include <bits/stdc++.h> #define fi first #define se second #define pb push_back #define mp make_p…
Given an unsorted array return whether an increasing subsequence of length 3 exists or not in the array. Formally the function should: Return true if there exists i, j, k such that arr[i] < arr[j] < arr[k] given 0 ≤ i < j < k ≤ n-1 else return…