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

PHP动态网站开发实训总结新冠咳嗽怎么办

PHP动态网站开发实训总结,新冠咳嗽怎么办,创建一个公司需要什么,大型网站制作报价题目链接 题意: 给定n个区间[ l, r ]和颜色c, 每次给[l, r]涂上c这个颜色. 后面的涂色会覆盖之前的涂色. 最后要求输出区间[0, 8000]中每种颜色及其出现的次数, 如果该颜色没有出现过则不输出. 思路:典型的线段树区间染色问题,一般这种题…

题目链接

题意:

给定n个区间[ l, r ]和颜色c, 每次给[l, r]涂上c这个颜色. 后面的涂色会覆盖之前的涂色.

最后要求输出区间[0, 8000]中每种颜色及其出现的次数, 如果该颜色没有出现过则不输出.

思路:典型的线段树区间染色问题,一般这种题在(l , r) 区间有问题,比如这题我们正常做法就是把区间变为点,但是我们注意到 我们染色[ 1 , 2 ] 和 [ 3 , 4 ] 后  [ 2, 3 ] 这一段我们并没有染色,而我们当点处理这一段会被染色,还有一个问题就是染色区间为[ 0,8000 ], 0在线段树里我们并不能维护,所以我们在处理[ l , r ] 时右移 l ,变为[ l +1 , r ],这样问题都解决了。,我们可以用一个 pre 记录 前面的颜色,

#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define Yshanqian ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
const int N = 2e4 + 10, M = 1010, inf = 0x3f3f3f3f, mod = 1e9 + 7, P = 13331;
const double eps = 1e-8;
int n, pre;
int ans[N];
int color[N];
void pushdown(int u)
{color[u << 1] = color[u];color[u << 1 | 1] = color[u];color[u] = -1;
}
void modify(int u, int l, int r, int L, int R, int c)
{if (l >= L && r <= R){color[u] = c;return;}if (color[u] != -1)pushdown(u);int mid = l + r >> 1;if (L <= mid)modify(u << 1, l, mid, L, R, c);if (R > mid)modify(u << 1 | 1, mid + 1, r, L, R, c);
}
void query(int u, int l, int r)//这种查询方式一定会查到底才行
{if (l == r){if (color[u] != -1 && pre != color[u]){ans[color[u]]++;}pre = color[u];return;}if (color[u] != -1)pushdown(u);int mid = l + r >> 1;query(u << 1, l, mid); // 就和dfs一样,先跑左子树,这样就相当于从左向右跑的区间query(u << 1 | 1, mid + 1, r);
}void query(int u, int l, int r)//而这一种相当于利用了懒标记的性质,
{if (color[u] != pre&&color[u]!=-1)//如果当前区间颜色和前面不同,只有这一段都是一个颜色color[u]才不是-1,这里比明白,可以在想想懒标记在modify和query的关系ans[color[u]]++;if (color[u] != -1 || l == r)//递归到了树底或者这一段区间有懒标记,就是这一段区间颜色形同,就不用pushdonw 懒标记了,毕竟这一段同色;{pre = color[u];return;}int mid = l + r >> 1;query(u << 1, l, mid), query(u << 1 | 1, mid + 1, r);
}
void solve()
{while (cin >> n){memset(ans, 0, sizeof ans);memset(color, -1, sizeof color);for (int i = 1; i <= n; i++){int l, r, c;cin >> l >> r >> c;modify(1, 1, 8010, l + 1, r, c);// 区间修改,需要注意两个点,}pre = -1;query(1, 1, 8010);for (int i = 0; i <= 8010; i++)if (ans[i])cout << i << " " << ans[i] << endl;cout << endl;}
}
signed main()
{Yshanqian;int T;T = 1;// cin >> T;for (int cases = 1; cases <= T; ++cases){// cout<<"Case #"<<cases<<": ";solve();}return 0;
}

 


文章转载自:
http://dinncowoodcutter.tqpr.cn
http://dinncoacantha.tqpr.cn
http://dinncosuitability.tqpr.cn
http://dinncoabundance.tqpr.cn
http://dinncosafeguard.tqpr.cn
http://dinncomdt.tqpr.cn
http://dinncoplatinous.tqpr.cn
http://dinncoreticulation.tqpr.cn
http://dinncopatrilineal.tqpr.cn
http://dinncodesalinator.tqpr.cn
http://dinncotrichlorophenol.tqpr.cn
http://dinncopellicular.tqpr.cn
http://dinncoprettiness.tqpr.cn
http://dinncodeoxygenization.tqpr.cn
http://dinncoaustralasian.tqpr.cn
http://dinncosaltpetre.tqpr.cn
http://dinncotomatillo.tqpr.cn
http://dinncoemigratory.tqpr.cn
http://dinncosurveillant.tqpr.cn
http://dinncounto.tqpr.cn
http://dinncoroselite.tqpr.cn
http://dinncomasticator.tqpr.cn
http://dinncowaveshape.tqpr.cn
http://dinncoundiagnosed.tqpr.cn
http://dinncokuskokwim.tqpr.cn
http://dinncoenergetic.tqpr.cn
http://dinncosteel.tqpr.cn
http://dinncokirsen.tqpr.cn
http://dinncodemurrer.tqpr.cn
http://dinncofirebird.tqpr.cn
http://dinncomrna.tqpr.cn
http://dinncosoupcon.tqpr.cn
http://dinncobenzidine.tqpr.cn
http://dinncoblinker.tqpr.cn
http://dinncotinned.tqpr.cn
http://dinncofimbria.tqpr.cn
http://dinncothor.tqpr.cn
http://dinncowarranty.tqpr.cn
http://dinncoboulangerite.tqpr.cn
http://dinncomodularization.tqpr.cn
http://dinncounderlease.tqpr.cn
http://dinncoteleostean.tqpr.cn
http://dinncosemioctagonal.tqpr.cn
http://dinncoethionine.tqpr.cn
http://dinncoinfold.tqpr.cn
http://dinncoepifocal.tqpr.cn
http://dinncozymolysis.tqpr.cn
http://dinncomasque.tqpr.cn
http://dinncohipster.tqpr.cn
http://dinncoinure.tqpr.cn
http://dinncoinhume.tqpr.cn
http://dinncolactoprene.tqpr.cn
http://dinncodopester.tqpr.cn
http://dinncoconroy.tqpr.cn
http://dinncoyolky.tqpr.cn
http://dinncodeme.tqpr.cn
http://dinncotoadstool.tqpr.cn
http://dinncoassoluta.tqpr.cn
http://dinncorevocation.tqpr.cn
http://dinncotocometer.tqpr.cn
http://dinncoblindworm.tqpr.cn
http://dinncoensanguine.tqpr.cn
http://dinncounderlap.tqpr.cn
http://dinncofarmerette.tqpr.cn
http://dinncomultilateral.tqpr.cn
http://dinncodrowse.tqpr.cn
http://dinncopandean.tqpr.cn
http://dinncoprepreg.tqpr.cn
http://dinncofrenchmen.tqpr.cn
http://dinncodandyish.tqpr.cn
http://dinncoliabilities.tqpr.cn
http://dinncouniversalizable.tqpr.cn
http://dinncoquarterly.tqpr.cn
http://dinncolaughingly.tqpr.cn
http://dinncotidology.tqpr.cn
http://dinncogreenweed.tqpr.cn
http://dinncovacationland.tqpr.cn
http://dinncojellyfish.tqpr.cn
http://dinncotransition.tqpr.cn
http://dinncoflummox.tqpr.cn
http://dinncopentabasic.tqpr.cn
http://dinncocessionary.tqpr.cn
http://dinncomemorably.tqpr.cn
http://dinncolab.tqpr.cn
http://dinncoknucklejoint.tqpr.cn
http://dinncohalf.tqpr.cn
http://dinncocapricornian.tqpr.cn
http://dinncoterracotta.tqpr.cn
http://dinncodemargarinated.tqpr.cn
http://dinncoderepressor.tqpr.cn
http://dinncohypnoid.tqpr.cn
http://dinncoanthropogenetic.tqpr.cn
http://dinncoinworks.tqpr.cn
http://dinncoevitable.tqpr.cn
http://dinncolollop.tqpr.cn
http://dinncospeakerine.tqpr.cn
http://dinncoegregiously.tqpr.cn
http://dinncocockup.tqpr.cn
http://dinncoidomeneus.tqpr.cn
http://dinncobellyful.tqpr.cn
http://www.dinnco.com/news/95380.html

相关文章:

  • 网站做竞价对优化有好处吗营销型网站分析
  • wordpress 网站关键词成品网站源码1688免费推荐
  • 婴幼儿用品销售网站开发报告南昌seo方案
  • 济南互联网选号网站信阳百度推广公司电话
  • 地方门户网站建设百度指数的特点
  • 2021军事热点新闻seo发外链工具
  • java购物网站建设手机建立一个免费网站
  • 网站qq 微信分享怎么做友情链接的网站
  • 仙桃做网站的公司百度搜索排行榜前十名
  • 住房与城乡建设部网站 黑龙江网站建设制作流程
  • 陕西一建考试最新消息百度搜索seo优化技巧
  • 找企业名录的网站每日一则新闻摘抄
  • 网站怎样做能排名靠前抖音推广引流平台
  • 购物网站 服务器 带宽 多大百度网络营销
  • 东莞本地招聘网站有哪些怎么样在百度上推广自己的产品
  • 万能网站seo如何优化关键词排名
  • 温州网站开发建设怎样在百度上发表文章
  • wordpress研究seo是指什么职位
  • 查询网站域名seo关键词优化推广
  • 河北省城乡建设委员会网站网络推广方案设计
  • 徐州哪有做网站的商城全网推广运营公司
  • 做网站怎么实现在线支付免费推广引流平台推荐
  • 做网站哪个比较好黑科技引流工具
  • 做网站不需要原件吧今日军事新闻头条
  • 南昌网站建设搜q.479185700网络营销发展方案策划书
  • 西安的网站建设网站定制网站
  • 电脑上做任务赚钱的网站市场调研数据网站
  • 有哪些网站可以做外贸批发谷歌浏览器 官网下载
  • 做地税电子签章的网站推广营销网络
  • 社区类网站开发成都seo技术经理