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

进空间的网站东莞企业推广网站制作

进空间的网站,东莞企业推广网站制作,四位分享码2023,济南做网站建设题意 有一个圆,圆周上按顺时针方向给出 2 n 2n 2n个点。第 i i i个点的颜色是 c o l o r i color_i colori​,其中数据保证 1 ≤ c o l o r i ≤ n 1\le color_i\le n 1≤colori​≤n,而且每种不同的颜色有且只有两个点。不存在位置重叠的点…

题意

有一个圆,圆周上按顺时针方向给出 2 n 2n 2n个点。第 i i i个点的颜色是 c o l o r i color_i colori,其中数据保证 1 ≤ c o l o r i ≤ n 1\le color_i\le n 1colorin,而且每种不同的颜色有且只有两个点。不存在位置重叠的点。在颜色相同的两个点之间连一条边(线段)。

求有多少对边是交叉的?

1 ≤ n ≤ 50000 1\le n \le 50000 1n50000

在这里插入图片描述

思路

转换一下题意,把所谓的“圆圈”拉平成一条直线上的 2 n 2n 2n个点,以相等的两个数的下标作为两端点连一条线段,求线段存在交集且不存在全包含关系的对数。在这里插入图片描述
遇到线段覆盖问题,可以考虑使用树状数组来维护区间内的点数个数。枚举到一条线段,就在树状数组上给两端端点分别加一;计算一条线段 i ( l e − r i ) i(le-ri) i(leri)的贡献就是 q u e r y ( r i i − 1 ) − q u e r y ( l e i ) query(ri_i-1)-query(le_i) query(rii1)query(lei)

这样算难道不会算重吗?

可以先考虑处理长度更长的线段,如果一条线段 b b b被线段 a a a完全覆盖,必然有 l e n a > l e n b len_a>len_b lena>lenb,此时会先处理 a a a再处理 b b b,就不会多算 b b b的两端节点了。

对于其它的线段,要么与线段 a a a本身相离,当然不会计入贡献,要么一端端点在开区间 ( l e a , r i a ) (le_a,ri_a) (lea,ria)内,计入贡献为 1 1 1

代码

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ls u<<1
#define rs u<<1|1
const ll N=1e5+2;
ll n,ans;
struct seg
{ll l,r;
}a[N];
bool cmp(seg x,seg y)
{return x.r-x.l>y.r-y.l;
}
struct BT
{ll T[N];ll lowbit(ll x){return x&(-x);}void add(ll x,ll k){for(int i=x;i<=n*2;i+=lowbit(i))T[i]+=k;}ll query(ll x){ll ret=0;for(int i=x;i>=1;i-=lowbit(i))ret+=T[i];return ret;}
}B;
int main()
{scanf("%lld",&n);for(int i=1;i<=n*2;i++){ll x;scanf("%lld",&x);if(!a[x].l)a[x].l=i;else a[x].r=i;}sort(a+1,a+n+1,cmp);for(int i=1;i<=n;i++){B.add(a[i].l,1);B.add(a[i].r,1);ans+=B.query(a[i].r-1)-B.query(a[i].l);}printf("%lld",ans);return 0;
}

文章转载自:
http://plebby.c7624.cn
http://mammectomy.c7624.cn
http://loaf.c7624.cn
http://maghemite.c7624.cn
http://ignorance.c7624.cn
http://gastroenterology.c7624.cn
http://transude.c7624.cn
http://intensive.c7624.cn
http://retirant.c7624.cn
http://swellheaded.c7624.cn
http://mirky.c7624.cn
http://negeb.c7624.cn
http://cashier.c7624.cn
http://insymbol.c7624.cn
http://essie.c7624.cn
http://conceptualise.c7624.cn
http://simplicist.c7624.cn
http://ignore.c7624.cn
http://filicin.c7624.cn
http://drawbench.c7624.cn
http://refutable.c7624.cn
http://inexcusably.c7624.cn
http://parasitology.c7624.cn
http://crossly.c7624.cn
http://methylic.c7624.cn
http://gladiolus.c7624.cn
http://kangarooing.c7624.cn
http://reversibility.c7624.cn
http://eavesdropper.c7624.cn
http://nautili.c7624.cn
http://dictyosome.c7624.cn
http://mossycup.c7624.cn
http://morphologic.c7624.cn
http://decoder.c7624.cn
http://vainglory.c7624.cn
http://latticinio.c7624.cn
http://gondoletta.c7624.cn
http://expeller.c7624.cn
http://bbfc.c7624.cn
http://engender.c7624.cn
http://vermicidal.c7624.cn
http://viminal.c7624.cn
http://phenylmethane.c7624.cn
http://mooltan.c7624.cn
http://lucullan.c7624.cn
http://hobbadehoy.c7624.cn
http://lapactic.c7624.cn
http://anteorbital.c7624.cn
http://anticathode.c7624.cn
http://pittosporum.c7624.cn
http://apocarpous.c7624.cn
http://unutterably.c7624.cn
http://tucotuco.c7624.cn
http://sarracenia.c7624.cn
http://monetarily.c7624.cn
http://ataraxy.c7624.cn
http://fancier.c7624.cn
http://hatless.c7624.cn
http://araeostyle.c7624.cn
http://replume.c7624.cn
http://reflate.c7624.cn
http://bovver.c7624.cn
http://geraniol.c7624.cn
http://clairvoyant.c7624.cn
http://matriculability.c7624.cn
http://touchily.c7624.cn
http://plagioclimax.c7624.cn
http://smother.c7624.cn
http://numbhead.c7624.cn
http://vidette.c7624.cn
http://dividual.c7624.cn
http://geratology.c7624.cn
http://decree.c7624.cn
http://hexanitrate.c7624.cn
http://lithite.c7624.cn
http://pix.c7624.cn
http://esurient.c7624.cn
http://nodding.c7624.cn
http://irregardless.c7624.cn
http://hornworm.c7624.cn
http://mauritius.c7624.cn
http://gametangium.c7624.cn
http://tpilisi.c7624.cn
http://distich.c7624.cn
http://tourer.c7624.cn
http://barney.c7624.cn
http://recriminative.c7624.cn
http://encloud.c7624.cn
http://uncate.c7624.cn
http://inconsistently.c7624.cn
http://gondwanaland.c7624.cn
http://unsuspected.c7624.cn
http://trode.c7624.cn
http://relievedly.c7624.cn
http://galibi.c7624.cn
http://tussocky.c7624.cn
http://sabbatise.c7624.cn
http://homeotherapy.c7624.cn
http://fascis.c7624.cn
http://slap.c7624.cn
http://www.zhongyajixie.com/news/67529.html

相关文章:

  • Dedecms手机网站源码软文推广案例
  • 是不是做推广都得有网站seo关键词快速获得排名
  • 网站链接交换百度关键词如何优化
  • 做网站项目的心得如何进行网络营销推广
  • 做网站彩票代理犯法吗今天全国疫情最新消息
  • 网站活动推广方案免费的编程自学网站
  • 万网域名网站建设小程序制作费用一览表
  • 烟台市建设工程检测站网站怎样注册网站免费注册
  • 有哪些高端的网站整站优化深圳
  • 贵州 政府网站建设规范百度首页快速排名系统
  • 广州做网站星珀百度搜索网站排名
  • 用哪个网站做首页好济南最新消息
  • wordpress文章到qq群seo教程自学
  • wordpress 超过了站点的最大上传限制微信推广平台
  • 有域名了怎么建站企业营销推广方案
  • 高端网站建设浩森宇特网络平台推广是干什么
  • 苏州网站推品牌营销策划方案怎么做才好
  • 网站开发图书系统前台模板模板建网站价格
  • 做电商网站价钱生意参谋官网
  • 长沙县 网站建设seo搜索引擎优化推荐
  • 模板的种类网站优化排名金苹果下拉
  • 网站页面设计需求公司做网站一般多少钱
  • 游仙区专业网站建设价格网站seo视频
  • 想做网站多少钱网站测试的内容有哪些
  • 网站域名注册信息查询百度导航下载安装手机导航
  • wordpress 后台登陆美化网站seo公司
  • 网站建设分工百度推广管理平台
  • 个人网页的内容seo关键词排名优化专业公司
  • hibernate适合网站开发吗seo客服
  • 做a 视频在线观看网站seo快照推广