Codeforces 113A-Grammar Lessons(实现)】的更多相关文章

A. Grammar Lessons time limit per test 5 seconds memory limit per test 256 megabytes input standard input output standard output Petya got interested in grammar on his third year in school. He invented his own language called Petya's. Petya wanted to…
原题传送门 我承认,比赛的时候在C题上卡了好久(最后也不会),15min水掉D后(最后还FST了..),看到E时已经只剩15min了.尽管一眼看出是离散化+线段树的裸题,但是没有时间写,实在尴尬. 赛后先照习惯码出线段树,提交上去WA4???看了好久没看出问题,怎么调都不对.这时TJW忽悠我:"我写的可持久化线段树啊,不用离散化了啊."我信了,码出主席树(实话说确实不用想那么多了,无脑动态开点就行了),提交上去TLE18???回头一问TJW:"我FST了啊."我:(…
题目描述 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 i…
Physical Education Lessons CodeForces - 915E 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…
C. Dancing Lessons   There are n people taking dancing lessons. Every person is characterized by his/her dancing skill ai. At the beginning of the lesson they line up from left to right. While there is at least one couple of a boy and a girl in the l…
https://codeforces.com/contest/893/problem/F 题意: 给一个有根树, 多次查询,每次查询对于$x$i点的子树中,距离$x$小于等于$k$的所有点中权值最小的一个 查询强制在线 题解: 显然,暴力就是,对于每次搜索深搜距离x小于$k$的所有点搜索 那么我们考虑优化 首先,查询对$x$距离小于$k$的所有点,等价于在整颗树上,查询$\forall dep(x)≤dep(i)≤dep(x)+k$中,在$x$子树中的点的最小值 那么,一个大胆的想法就是,对于每…
[题目]E. Physical Education Lessons [题意]10^9范围的区间覆盖,至多3*10^5次区间询问. [算法]线段树 [题解]每次询问至多增加两段区间,提前括号分段后线段树. #include<cstdio> #include<cctype> #include<set> #include<algorithm> using namespace std; int read(){ ,t=; ; +c-';}while(isdigit(c…
http://codeforces.com/problemset/problem/915/E 大概有几种思路: 1.动态开点线段树+标记下传 #1.1标记永久化:想了一会没想出来 1.2可以先扫一遍询问把所有需要的点建出来,然后pushdown就不管没建出来的点了,空间跟标记永久化一样 2.离散化+线段树 3.用splay维护区间(估计没人愿意去写) 4.用一个set<pair<int,int>>记所有非工作日(或工作日)区间,修改就暴力找到相关的区间去改 由于每一次操作最多多出O…
E. Physical Education Lessons 题目:一段长度为n的区间初始全为1,每次成段赋值0或1,求每次操作后的区间总和.(n<=1e9,q<=3e5) 题意:用线段树做的话,没什么思维量,主要是空间复杂度的问题.因此采用动态开点的办法,即需要用到的节点,在使用前分配内存,没有用到的就虚置.这样每次操作新增的节点约logn个.则q次修改需要的空间大约是qlogn.但是,在这个数量级上尽可能开的再大一些,防止RE. #include<bits/stdc++.h> #…
提供两种思路 一种线段树区间更新 另一种用map维护连续的区间,也是题解的思路 第二种很难写(我太渣,看了别人的代码,发现自己写的太烦了) #include<iostream> #include<map> #include<iostream> #include<cstring> #include<cstdio> #include<set> #include<vector> #include<queue> #in…