[Educational Codeforces Round 36]E. Physical Education Lessons

[Educational Codeforces Round 36]E. Physical Education Lessons

<题意概括>

给定一个长度为$N\left(1\leqslant N\leqslant10^{9}\right)$的区间

$Q\left(1\leqslant Q\leqslant3\cdot10^{5}\right)$次将区间$\left[L,R\right]$Set01,每次Set后输出区间总和

<做法>

$10_{9}$的范围显然不可能是朴素线段树

那么我们可以考虑离散化

将从始至终作为一个整体改变的区间缩为一个点(即对于)

原文地址:https://www.cnblogs.com/Trisolaris/p/Codeforces-915E.html

时间: 2024-08-03 19:53:17

[Educational Codeforces Round 36]E. Physical Education Lessons的相关文章

Educational Codeforces Round 36

Educational Codeforces Round 36 A. Garden 题目描述:给定\(n\)个数,找出能整除\(m\)的最大的数(假设是\(num\)),输出\(\frac{m}{num}\). solution 枚举. 时间复杂度:\(O(n)\) B. Browser 题目描述:有\(n\)个标签页,当前在第\(i\)页,有下面六个操作: 向左移动一个页面,即\(i-1\) 向右移动一个页面, 即\(i+1\) 关闭左边一个页面,即第\(i-1\)个页面 关闭右边一个页面,即

Educational Codeforces Round 36 (Rated for Div. 2)

Educational Codeforces Round 36 (Rated for Div. 2) F. Imbalance Value of a Tree You are given a tree T consisting of n vertices. A number is written on each vertex; the number written on vertex i is ai. Let's denote the function I(x,?y) as the differ

Educational Codeforces Round 36 (Rated for Div. 2) 题解

Educational Codeforces Round 36 (Rated for Div. 2) 题目的质量很不错(不看题解做不出来,笑 Codeforces 920C 题意 给定一个\(1\)到\(n\)组成的数组,只可以交换某些相邻的位置,问是否可以将数组调整为升序的 解题思路 首先如果每个数都能通过交换到它应该到的位置,那么就可以调整为升序的. 但实际上交换是对称的,如果应该在的位置在当前位置前方的数都交换完成,那么整体就是排好序的,因为不可能所有不在相应位置的数都在相应位置的后方.

Educational Codeforces Round 36 (Rated for Div. 2) E. Physical Education Lessons(动态开点线段树)

链接: https://codeforces.com/problemset/problem/915/E 题意: 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 atten

【CodeForces】915 E. Physical Education Lessons 线段树

[题目]E. Physical Education Lessons [题意]10^9范围的区间覆盖,至多3*10^5次区间询问. [算法]线段树 [题解]每次询问至多增加两段区间,提前括号分段后线段树. #include<cstdio> #include<cctype> #include<set> #include<algorithm> using namespace std; int read(){ char c;int s=0,t=1; while(!i

Educational Codeforces Round 36 (Rated for Div. 2) ---d

D. Almost Acyclic Graph 首先判环可以用拓扑来实现. 暴力解法自然是枚举每一条边,删除,判断是否存在环. 解法一: 对于指向同一个点的边,在拓扑排序中看删除他们事实上是等价的,即那个点入度-1,那么我们枚举所有的点即可. 1 #include<bits/stdc++.h> 2 using namespace std; 3 const int inf=1e5+10; 4 int n,m; 5 int tot,fi[inf],nxt[inf],to[inf],in[inf];

【Educational Codeforces Round 36 A】 Garden

[链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 枚举用哪一个桶就好 [代码] #include <bits/stdc++.h> using namespace std; int n,k,x; int main(){ #ifdef LOCAL_DEFINE freopen("rush_in.txt", "r", stdin); #endif ios::sync_with_stdio(0),cin.tie(0); cin >>

Educational Codeforces Round 36 (Rated for Div. 2) G. Coprime Arrays

求a_i 在 [1,k]范围内,gcd(a_1,a_2...,a_n) = 1的a的数组个数. F(x)表示gcd(a_1,a_2,...,a_n) = i的a的个数 f(x)表示gcd(a_1,a_2,...,a_n) = ki的a的个数(实际上就是i的倍数) f(x) = segma(x | d) F(d) F(x) = segma(x | d) mu(d / x) * f(d) F(1) = segma(d,1,k) mu(d) * f(d) f(d) = (k / d)^n 由于k变化时

Codeforces 915 E Physical Education Lessons

题目描述 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