正文
增加 5 行删除 5 行
6 行未改动78910111213141514 行未改动30313233343536373814 行未改动53545556575859606162632 行未改动66676869707172737417 行未改动6 行未改动做完了,注意判一下边界。时间复杂度 $O(n^2)$。```cpp#include <iostream>#include <cstring>#include <algorithm>#include <queue>#define int long longusing namespace std;14 行未改动signed main(){int T;cin >> T;while (T--){memset(dp, -0x3f, sizeof(dp));dp[0] = 0;14 行未改动sa[a[j].r]++;}if (a[i].l < a[j].l && a[i].r == a[j].r){sb[a[j].l]++;}if (a[i].l == a[j].l && a[i].r == a[j].r){t++;}if (a[j].l == a[j].r && a[j].l == a[i].l)2 行未改动}}for (int j = 1; j <= 2*n; j++) sa[j] += sa[j-1];for (int j = 2*n; j >= 1; j--) sb[j] += sb[j+1];for (int j = 1; j <= 2*n; j++) // 枚举一下分割点{cnt = max(cnt, sa[j] + sb[j]);}17 行未改动6 行未改动78910111213141514 行未改动30313233343536373814 行未改动53545556575859606162632 行未改动66676869707172737417 行未改动6 行未改动做完了,注意判一下边界。时间复杂度 $O(n^2)$。```cpp#include <iostream>#include <cstring>#include <algorithm>#include <queue>#define int long longusing namespace std;14 行未改动signed main(){int T;cin >> T;while (T--){memset(dp, -0x3f, sizeof(dp));dp[0] = 0;14 行未改动sa[a[j].r]++;}if (a[i].l < a[j].l && a[i].r == a[j].r){sb[a[j].l]++;}if (a[i].l == a[j].l && a[i].r == a[j].r){t++;}if (a[j].l == a[j].r && a[j].l == a[i].l)2 行未改动}}for (int j = 1; j <= 2*n; j++) sa[j] += sa[j-1];for (int j = 2*n; j >= 1; j--) sb[j] += sb[j+1];for (int j = 1; j <= 2*n; j++) // 枚举一下分割点{cnt = max(cnt, sa[j] + sb[j]);}17 行未改动