跳到正文

个人记录

一些错误

__Tao__约 1 分钟
原文
文章信息与版本

文章信息

发布
2023年8月3日
收录
2026年8月27日
更新
2026年11月15日
篇幅
约 1 分钟

版本

  1. v1当前

近期错误

  • TLE,RE时调试要输出endl,否则可能输出偏少导致判断寄的位置偏前。
  • sizx+=sizysiz_x+=siz_y写到了最里层循环内。
  • 转移,移动顺序不对。导致被覆盖或重复转移。

一种错误的LIS写法

最小的不一定是最长的。

C++
#include <bits/stdc++.h>
#define N 100005
using namespace std;
int n, a[N], b[N];

int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) {
		scanf("%d", &a[i]);
	}
	int top=0,ans=0;
	for(int i=1;i<=n;i++){
		while(top&&a[b[top]]>a[i]){
			top--;
		}
		b[++top]=i;
		ans=max(ans,top);
	}
	printf("%d",ans);
	return 0;
}
/*
hack:
5
1 3 4 2 5
*/
原文
存档评论1 条抓取于