跳到正文

生活·游记

局部变量毁我OI

_Grylls_约 1 分钟
原文

这是 2025年12月4日 存档的第 1 版,不是当前版本。查看当前版本

文章信息与版本

文章信息

发布
2025年12月4日
收录
2025年12月12日
更新
2026年11月13日
篇幅
约 1 分钟

版本

  1. v2当前
  2. v1

省流 : T2 100-> 56,200-> 156

哦,局部变量要赋初始值,神经病,没事,明年再来,哦,明年是不是要中考了

万世师表

C++
	for(int h=1;h<n;h++)
	{
		int pos;  //<---------------这里
		for(int i=1;i<=n;i++)
			if(2ll*a[i]<=a[h]){pos=i;break;}
		while(pos<=n+1&&a[pos]>=a[h]-a[h+1]) pos++;
		for(int k=h+1;k<=n;k++)
		{
			if(2ll*a[k]<=a[h]) continue;
			while(pos-1>k&&a[pos-1]<a[h]-a[k]) 
				pos--;
			if(m-1-h<0) continue;
			int cnt=C(k-2,m-1-h);
			ans=(1ll*cnt*sum[pos]%mod+ans)%mod;
		}
	}