From 6e1b16d77596639d0fafcc94e0fa53bc5e1e8da7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BB=84=E6=B5=B7?= <10402852@qq.com> Date: Mon, 4 Mar 2024 10:11:56 +0800 Subject: [PATCH] 'commit' --- TangDou/AcWing_TiGao/T1/LIS/1017.md | 16 ++++++++-------- TangDou/AcWing_TiGao/T1/LIS/1017_TanXin.cpp | 16 ++++++++-------- TangDou/AcWing_TiGao/T1/LIS/896.md | 4 ++-- 3 files changed, 18 insertions(+), 18 deletions(-) diff --git a/TangDou/AcWing_TiGao/T1/LIS/1017.md b/TangDou/AcWing_TiGao/T1/LIS/1017.md index ff2d0ff..ad39c24 100644 --- a/TangDou/AcWing_TiGao/T1/LIS/1017.md +++ b/TangDou/AcWing_TiGao/T1/LIS/1017.md @@ -149,32 +149,32 @@ int main() { fl = 0, gl = 0; cin >> n; - for (int i = 1; i <= n; i++) cin >> a[i]; + for (int i = 0; i < n; i++) cin >> a[i]; // 正着求 - f[++fl] = a[1]; - for (int i = 2; i <= n; i++) { + f[0] = a[0]; + for (int i = 1; i < n; i++) { if (a[i] > f[fl]) f[++fl] = a[i]; else - *lower_bound(f + 1, f + 1 + fl, a[i]) = a[i]; + *lower_bound(f, f + fl, a[i]) = a[i]; } // 前半程的结果 res = fl; // 反着求 - g[++gl] = a[n]; - for (int i = n - 1; i >= 1; i--) { + g[0] = a[n-1]; + for (int i = n - 1; i >= 0; i--) { if (a[i] > g[gl]) g[++gl] = a[i]; else - *lower_bound(g + 1, g + 1 + gl, a[i]) = a[i]; + *lower_bound(g, g + gl, a[i]) = a[i]; } // pk的最大结果 res = max(res, gl); // 输出 - printf("%d\n", res); + printf("%d\n", res + 1); } return 0; } diff --git a/TangDou/AcWing_TiGao/T1/LIS/1017_TanXin.cpp b/TangDou/AcWing_TiGao/T1/LIS/1017_TanXin.cpp index 7daff92..b965294 100644 --- a/TangDou/AcWing_TiGao/T1/LIS/1017_TanXin.cpp +++ b/TangDou/AcWing_TiGao/T1/LIS/1017_TanXin.cpp @@ -21,32 +21,32 @@ int main() { fl = 0, gl = 0; cin >> n; - for (int i = 1; i <= n; i++) cin >> a[i]; + for (int i = 0; i < n; i++) cin >> a[i]; // 正着求 - f[++fl] = a[1]; - for (int i = 2; i <= n; i++) { + f[0] = a[0]; + for (int i = 1; i < n; i++) { if (a[i] > f[fl]) f[++fl] = a[i]; else - *lower_bound(f + 1, f + 1 + fl, a[i]) = a[i]; + *lower_bound(f, f + fl, a[i]) = a[i]; } // 前半程的结果 res = fl; // 反着求 - g[++gl] = a[n]; - for (int i = n - 1; i >= 1; i--) { + g[0] = a[n - 1]; + for (int i = n - 1; i >= 0; i--) { if (a[i] > g[gl]) g[++gl] = a[i]; else - *lower_bound(g + 1, g + 1 + gl, a[i]) = a[i]; + *lower_bound(g, g + gl, a[i]) = a[i]; } // pk的最大结果 res = max(res, gl); // 输出 - printf("%d\n", res); + printf("%d\n", res + 1); } return 0; } \ No newline at end of file diff --git a/TangDou/AcWing_TiGao/T1/LIS/896.md b/TangDou/AcWing_TiGao/T1/LIS/896.md index 394d645..0f52619 100644 --- a/TangDou/AcWing_TiGao/T1/LIS/896.md +++ b/TangDou/AcWing_TiGao/T1/LIS/896.md @@ -187,14 +187,14 @@ const int N = 100010; int n, a[N]; -// 数组模拟栈 +// 数组模拟 int f[N], fl; int main() { cin >> n; for (int i = 0; i < n; i++) cin >> a[i]; - // 1、首个元素入栈 + // 1、首个元素 f[0] = a[0]; // 2、后续元素开始计算