当前位置: 首页 > news >正文

传业做微采商城网站网站打开太慢

传业做微采商城网站,网站打开太慢,网架制作厂,南宁做企业网站https://www.luogu.com.cn/problem/CF1762F 分析性质,就是我们选的数要么递增,要么递减(非严格)然后很明细是ds套dp, f i f_i fi​ 表示以 i i i 开头的答案然后考虑如何转移(ds套dp难点反而在转移而不是…

https://www.luogu.com.cn/problem/CF1762F

  • 分析性质,就是我们选的数要么递增,要么递减(非严格)
  • 然后很明细是ds套dp, f i f_i fi 表示以 i i i 开头的答案
  • 然后考虑如何转移(ds套dp难点反而在转移而不是状态,因为要考虑如何和ds结合)
  • 转移的话,要么从位置考虑,要么从值域考虑
  • 从值域考虑,就从后面比它大且最小的转移,似乎不知道怎么搞
  • 从位置考虑,就是从第一个在 [ a i , a i + k ] [a_i,a_i+k] [ai,ai+k] 内的数转移。我们考虑会漏掉值域在 [ a i + 1 , a j − 1 ] [a_i+1,a_j-1] [ai+1,aj1] 的数,但这可以直接套ds来做了。至于大于 a j a_j aj 的会在 f j f_j fj 里算
#include<bits/stdc++.h>
using namespace std;
#define int long long
inline int read(){int x=0,f=1;char ch=getchar(); while(ch<'0'||
ch>'9'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9'){
x=(x<<1)+(x<<3)+(ch^48);ch=getchar();}return x*f;}
#define Z(x) (x)*(x)
#define pb push_back
//mt19937 rand(time(0));
//mt19937_64 rand(time(0));
//srand(time(0));
#define N 500010
//#define M
//#define mo
struct node {int x, id; bool operator < (const node &A) const {return id < A.id; }
}b[N]; 
int n, m, i, j, k, T;
int ans, a[N], mp[N], nxt[N], f[N], l; 
set<node>s; 
set<node>::iterator it; struct Binary_tree {int cnt[N]; void add(int x, int y) {while(x<N) cnt[x]+=y, x+=x&-x; }int que(int x) {int ans = 0; while(x) ans+=cnt[x], x-=x&-x; return ans; }
}Bin;void calc() {for(i=1; i<=n; ++i) b[i].x = a[i], b[i].id = i; 	auto cmp = [&] (node x, node y) -> bool {if(x.x == y.x) return x.id > y.id; return x.x > y.x; }; sort(b+1, b+n+1, cmp); s.clear(); for(i=l=1; i<=n; ++i) {while(b[l].x>b[i].x+k) s.erase(b[l]), ++l; it = s.upper_bound({0, b[i].id}); if(it == s.end()) nxt[b[i].id] = 0;  else nxt[b[i].id] = (it -> id); s.insert(b[i]); }
//	for(i = 1; i <= n; ++i) printf("%d ", nxt[i]); printf("\n"); for(i=n; i>=1; --i) {j=nxt[i]; f[i]=f[j]+1; if(nxt[i]==0) f[i]+=Bin.que(a[i]+k)-Bin.que(a[i]-1); else f[i]+=Bin.que(a[nxt[i]]-1)-Bin.que(a[i]-1); ans+=f[i]; Bin.add(a[i], 1); 
//		printf("%lld (%lld %lld)", f[i], f[j]); }
//	printf("\n"); for(i=1; i<=n; ++i) Bin.add(a[i], -1); 
}signed main()
{
//	freopen("in.txt", "r", stdin);
//	freopen("out.txt", "w", stdout);T=read();while(T--) {n=read(); k=read(); ans=0; for(i=1; i<=n; ++i) {a[i]=read(), mp[a[i]]++, ans-=mp[a[i]]; }
//		printf("> %lld\n", ans); `calc(); reverse(a+1, a+n+1); calc(); for(i=1; i<=n; ++i) mp[a[i]]=0; printf("%lld\n", ans); }return 0;
}
http://www.15wanjia.com/news/160149.html

相关文章:

  • 上海网站建设培训学校西安seo公司哪家好
  • 自己做的网站出现乱码中小企业网站营销
  • 大连哪里做网站好seo技术服务外包公司
  • 专门做电子书的网站有哪些网页表单制作步骤
  • 家装网站模板下载网站建设政策
  • 怎么用html做图片展示网站长沙行业网站建设
  • 百度移动网站检测做阿里国际网站多少钱
  • 快速建站网站wordpress reddit主题
  • 用wordpress做外贸网站个体户能做网站备案吗
  • 菏泽最好的网站建设公司专门做漫画的网站
  • 网站调优企业外贸网络推广
  • 做同城网站还有机会吗软件开发多少钱一个月
  • 网站建设平台案例asp_asp.net_php哪种做网站最好?
  • 东莞营销网站建设服务网站改版需求
  • 山西做网站推广wordpress中文主
  • 网站做广告投放 做销售线索预估河北省建设局网站材料备案
  • 怎么做网站数据库nodejs 网站开发
  • 服装网站建设教程dedecms新网站 上传到万网的空间
  • jsp网站安全性电商网站的意义
  • 聚名网站手机版房屋3d效果图设计软件
  • 好三网网站桐乡建设规划局网站
  • 违禁网站用什么浏览器wordpress状态修改
  • 网站上的图片多大合适重庆企业网站设计维护
  • 一个网站的域名突然换了室内装潢设计师
  • 深圳定制网站做一个谷歌网站多少钱
  • 大连响应式网站制作昆山做网站找文博
  • 临沂免费模板建站济宁专业网站开发公司
  • 国际化网站设计wordpress多个站点
  • 绍兴柯桥哪里有做网站的为了 门户网站建设
  • 网站建设框架怎么做seo必备软件