日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

Codeforces 915 E Physical Education Lessons

發(fā)布時間:2023/11/30 编程问答 37 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Codeforces 915 E Physical Education Lessons 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

題目描述

This year Alex has finished school, and now he is a first-year student of Berland State University. For him it was a total surprise that even though he studies programming, he still has to attend physical education lessons. The end of the term is very soon, but, unfortunately, Alex still hasn't attended a single lesson!

Since Alex doesn't want to get expelled, he wants to know the number of working days left until the end of the term, so he can attend physical education lessons during these days. But in BSU calculating the number of working days is a complicated matter:

There are?nn?days left before the end of the term (numbered from?11?to?nn?), and initially all of them are working days. Then the university staff sequentially publishes?qq?orders, one after another. Each order is characterised by three numbers?ll?,?rr?and?kk?:

  • If?k=1k=1?, then all days from?ll?to?rr?(inclusive) become non-working days. If some of these days are made working days by some previous order, then these days still become non-working days;
  • If?k=2k=2?, then all days from?ll?to?rr?(inclusive) become working days. If some of these days are made non-working days by some previous order, then these days still become working days.

Help Alex to determine the number of working days left after each order!

輸入輸出格式

輸入格式:

?

The first line contains one integer?nn?, and the second line — one integer?qq?(?1<=n<=10^{9}1<=n<=109?,?1<=q<=3·10^{5}1<=q<=3?105) — the number of days left before the end of the term, and the number of orders, respectively.

Then?qq?lines follow,?ii?-th line containing three integers?l_{i}li??,?r_{i}ri??and?k_{i}ki??representing?ii?-th order (?1<=l_{i}<=r_{i}<=n1<=li?<=ri?<=n?,?1<=k_{i}<=21<=ki?<=2?).

?

輸出格式:

?

Print?qq?integers.?ii?-th of them must be equal to the number of working days left until the end of the term after the first?iiorders are published.

?

輸入輸出樣例

輸入樣例#1:?
4 6 1 2 1 3 4 1 2 3 2 1 3 2 2 4 1 1 4 2 輸出樣例#1:? 2 0 2 3 1 4

下午去湘江邊的橘子洲van了一圈,然而明天就要去雅禮報道了hhhh


很明顯n<=10^9肯定不能用普通的線段樹做,雖然可能離散化完了之后會有奇淫技巧能做。。。。
但是我首先想到的是動態(tài)開點直接打標(biāo)機(jī)下傳、、、畢竟線段樹一次操作涉及的節(jié)點數(shù)是log n級別的,就算是區(qū)間操作+需要標(biāo)記下傳的話,
需要的空間也只是常數(shù)大了大,復(fù)雜度依然是log n的,而且很多操作還會有重復(fù)的區(qū)間呢。

于是我就動態(tài)開點+線段樹打tag瞎做了做,,,本地垃圾筆記本3s才能過極端數(shù)據(jù),,,,不過codeforces的評測機(jī)跑的飛快,硬生生的縮成了300+ms。


#include<iostream> #include<cstdio> #include<cstdlib> #include<cstring> #include<algorithm> #include<cmath> #define ll long long #define maxn 200005 using namespace std; struct node{int lc,rc;int tag,sum; }nil[maxn*71]; int n,le,ri,tot; int q,opt,cnt=1;inline void work(int v,int tmp,int len){if(tmp==-1) nil[v].tag=-1,nil[v].sum=0;else nil[v].tag=1,nil[v].sum=len; }inline void pushdown(int o,int l,int r){int ls=nil[o].lc,rs=nil[o].rc,mid=l+r>>1;if(nil[o].tag==-1){nil[o].tag=0;work(ls,-1,mid-l+1);work(rs,-1,r-mid);}else if(nil[o].tag==1){nil[o].tag=0;work(ls,1,mid-l+1);work(rs,1,r-mid);} }void update(int u,int l,int r){if(l>=le&&r<=ri){int pre=nil[u].sum;work(u,opt,r-l+1);tot+=nil[u].sum-pre;return;}if(!nil[u].lc) nil[u].lc=++cnt;if(!nil[u].rc) nil[u].rc=++cnt;pushdown(u,l,r);int mid=l+r>>1;if(le<=mid) update(nil[u].lc,l,mid);if(ri>mid) update(nil[u].rc,mid+1,r);nil[u].sum=nil[nil[u].lc].sum+nil[nil[u].rc].sum; }int main(){ // freopen("data.in","r",stdin); // freopen("data.out","w",stdout);int root=1;nil[1]=(node){0,0,0,0};scanf("%d%d",&n,&q);while(q--){scanf("%d%d%d",&le,&ri,&opt);opt=(opt==2?-1:1);update(root,1,n);printf("%d\n",n-tot);}return 0; }

?

轉(zhuǎn)載于:https://www.cnblogs.com/JYYHH/p/8406106.html

總結(jié)

以上是生活随笔為你收集整理的Codeforces 915 E Physical Education Lessons的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。

主站蜘蛛池模板: 在线观看日本中文字幕 | 国产性xxxx高清 | 日韩免费a| h亚洲| 欧美特级黄色片 | 午夜视频国产 | 欧美福利一区二区三区 | 欧美黄色大片免费观看 | 最新精品在线 | 小镇姑娘国语版在线观看免费 | 日韩av专区 | 中日精品一色哟哟 | 在线观看三级视频 | 免费在线一级片 | 日韩视频在线观看一区二区 | 色91精品久久久久久久久 | 天天综合天天干 | 国产成人在线免费观看视频 | 摸摸摸bbb毛毛毛片 午夜爽爽影院 | www久久 | 国产精品伦理 | 久久九九99 | 国产精品亚洲欧美 | 91爱爱com| 日本一区二区三区免费视频 | 国产精品免费一区 | 成人28深夜影院 | 色婷婷狠狠操 | 日韩成人综合 | 欧美另类极品 | 日韩精品视频观看 | 关之琳三级全黄做爰在线观看 | 免费毛片网站 | 日韩黄网| 精品久久久亚洲 | 久久久久久无码精品人妻一区二区 | 综合五月婷 | 欧美成人做爰大片免费看黄石 | 亚洲欧美视频在线播放 | 网站在线观看你懂的 | 日本作爱视频 | 玉足脚交榨精h文 | 蜜桃视频在线观看一区 | 亚洲精品福利视频 | 无码精品人妻一区二区三区影院 | av网页在线| 国产欧美日韩综合精品一区二区 | 美女131爽爽爽做爰视频 | 波多野结衣在线影院 | 欧美午夜视频在线观看 | 在厨房拨开内裤进入毛片 | 影音先锋激情 | 国产精品久久久一区二区 | 综合视频一区二区 | 亚洲特黄特色 | 黄视频网站免费看 | 欧美黑人做爰爽爽爽 | 黄色小电影网址 | 日韩一区二区免费在线观看 | 操极品少妇| 蜜臀av性久久久久蜜臀aⅴ流畅 | 久久久无码人妻精品一区 | 国产成人在线精品 | 亚洲午夜毛片 | 成人动漫在线观看视频 | 中国女人真人一级毛片 | 日日干天天爽 | 人人看超碰 | 黄色网址进入 | 日韩中文在线观看 | 淫五月天| 久久久久www| 日韩高清一区二区 | 欧美精品一区二区久久婷婷 | 91美女免费看 | 国产欧美综合一区二区三区 | 三浦理惠子av在线播放 | 欧美成人r级一区二区三区 中文无码一区二区三区在线观看 | 长腿校花无力呻吟娇喘的视频 | 18岁毛片 | 蜜桃久久久久久久 | 国产福利观看 | 成年黄色网 | 国产成人亚洲一区二区 | 国产精品一区二区三区免费看 | 中文字幕在线视频一区二区 | 亚洲综合图区 | 91在线观看免费视频 | 欧美视频三区 | 一级黄色在线视频 | 精品国产免费一区二区三区 | 不卡在线一区二区 | 一女二男一黄一片 | 天天插天天狠 | av在线h| 九色porny自拍视频 | 秋霞精品| av一区二区三区 | 国产1区|