![](https://img-blog.csdnimg.cn/20190918140129601.png?x-oss-process=image/resize,m_fixed,h_224,w_224)
线段树
文章平均质量分 89
线段树
_sky123_
这个作者很懒,什么都没留下…
展开
-
2021CCPC桂林 B. A Plus B Problem
裸线段树板题,非常恶心#include<bits/stdc++.h>using namespace std;const int N = 1e6 + 10;struct { int l, r, len; int val, suf0, suf9; bool tag0, tag9;} t[N << 2];int a[2][N], b[N];inline void update(int p) { if (t[p << 1 | 1]原创 2021-11-08 10:54:53 · 1682 阅读 · 0 评论 -
The 2021 ICPC Asia Regionals Online Contest (II) L.Euler Function
The Euler function, φφφ, is known to be important in math theory. Given a positive integer nnn, φ(n)φ(n)φ(n) is defined as the number of integers in [1,n][1,n][1,n] that are co-prime with nnn. For example, φ(1)=1,φ(10)=4,φ(11)=10φ(1)=1,φ(10)=4,φ(11)=10φ(1)原创 2021-09-29 18:47:17 · 255 阅读 · 0 评论 -
2021牛客暑期多校训练营1 J.Journey among Railway Stations
题目链接题目描述There are n{n}n railway stations lying on a straight line, numbered from 1{1}1 to n{n}n. A strange thing is, each railway station only opens for a continuous period of time [ui,vi][u_i, v_i][ui,vi] every day. In other words, if a train arrives原创 2021-07-21 12:52:10 · 190 阅读 · 0 评论 -
2020ICPC EC-Final G.Prof. Pang’s sequence
题目链接Prof. Pang is given a fixed sequence a1,…,ana_1, \ldots, a_na1,…,an and mmm queries.Each query is specified by two integers lll and rrr satisfying 1≤l≤r≤n1\le l\le r\le n1≤l≤r≤n. For each query, you should answer the number of pairs of integers (i,原创 2021-05-12 15:44:38 · 955 阅读 · 2 评论 -
牛客练习赛80 E.覆盖
题目链接题目描述给出 nnn 条线段 [l1,r1],…,[ln,rn][l_1,r_1],…,[l_n,r_n][l1,r1],…,[ln,rn] ,qqq 次询问编号在 [a,b][a,b][a,b] 内的线段覆盖的总长度是多少。线段覆盖的总长度定义为:在一条无限长的数轴上有多少整点,使得该整点至少被一条线段覆盖到。输入描述:第一行两个整数 n,qn,qn,q ;接下来 nnn 行每行两个整数 li,ril_i,r_ili,ri ,表示一条线段;接下来 qqq 行每行两个整数原创 2021-04-13 00:16:52 · 156 阅读 · 0 评论 -
Codeforces Round #707 (Div. 1) E. Subset Trick
题目链接Vanya invented an interesting trick with a set of integers.Let an illusionist have a set of positive integers SSS. He names a positive integer xxx. Then an audience volunteer must choose some subset (possibly, empty) of SSS without disclosing it to t原创 2021-03-26 20:39:01 · 151 阅读 · 0 评论 -
Educational Codeforces Round 90 (Rated for Div. 2) G. Pawns
题目链接You are given a chessboard consisting of nnn rows and nnn columns. Rows are numbered from bottom to top from 111 to nnn. Columns are numbered from left to right from 111 to nnn. The cell at the intersection of the xxx-th column and the yyy-th row is d原创 2021-02-20 23:41:02 · 164 阅读 · 0 评论 -
Educational Codeforces Round 95 (Rated for Div. 2) G. Three Occurrences
题目链接You are given an array aaa consisting of nnn integers. We denote the subarray a[l..r]a[l..r]a[l..r] as the array [al,al+1,…,ar][a_l, a_{l + 1}, \dots, a_r][al,al+1,…,ar] (1≤l≤r≤n1 \le l \le r \le n1≤l≤r≤n).A subarray is considered good if every in原创 2021-02-13 18:00:04 · 190 阅读 · 2 评论 -
Codeforces Round #698 (Div. 2) E. Nezzar and Binary String
题目链接Nezzar has a binary string sss of length nnn that he wants to share with his best friend, Nanako. Nanako will spend qqq days inspecting the binary string. At the same time, Nezzar wants to change the string sss into string fff during these qqq days, b原创 2021-02-01 23:23:24 · 259 阅读 · 0 评论 -
2020ICPC小米网络赛第二场 C.Data Structure Problem
题目链接题目描述Bobo has two sequences a1,a2,…,ana_1, a_2, \ldots, a_na1,a2,…,an and b1,b2,…,bnb_1, b_2, \ldots, b_nb1,b2,…,bn. He would like to perform the following operations:1 x y\text{1 }x\ y1 x y, change the value of axa_xax to原创 2020-12-31 00:21:13 · 207 阅读 · 0 评论 -
2020CCPC 威海 G Caesar Cipher
题目链接Have you ever heard of the Caesar cipher? It is one of the simplest and best-known encryption techniques. Named after Julius Caesar, he used this cipher to communicate with his generals.Caesar cipher is a type of substitution cipher in which each let原创 2020-12-17 19:47:58 · 280 阅读 · 0 评论 -
Codeforces Round #668 (Div. 2)E. Fixed Point Removal
Let a1,…,ana_1,\dots,a_na1,…,an be an array of nnn positive integers. In one operation, you can choose an index iii such that ai=ia_i=iai=i, and remove aia_iai from the array (after the removal, the remaining parts are concatenated).The weight of aaa原创 2020-09-08 19:59:53 · 204 阅读 · 0 评论 -
AtCoder Beginner Contest 177 F - I hate Shortest Path Problem
题目链接Problem StatementThere is a grid of squares with H+1H+1H+1 horizontal rows and WWW vertical columns.You will start at one of the squares in the top row and repeat moving one square right or down. However, for each integer iii from 111 through HHH, y原创 2020-08-30 01:14:42 · 435 阅读 · 1 评论 -
Codeforces Round #665 (Div. 2) F. Reverse and Swap
题目链接You are given an array a of length 2n2^n2n. You should process qqq queries on it. Each query has one of the following 444 types:Replace(x,k)Replace(x,k)Replace(x,k) — change axa_xax to kkk;Reverse(k)Reverse(k)Reverse(k) — reverse each subarray原创 2020-08-24 09:49:17 · 203 阅读 · 0 评论 -
AtCoder Beginner Contest 176 E - Bomber
Problem StatementWe have a two-dimensional grid with H×WH×WH×W squares. There are MMM targets to destroy in this grid - the position of the iii-th target is (hi,wi)(h_i,w_i)(hi,wi).Takahashi will choose one square in this grid, place a bomb there,原创 2020-08-23 13:35:51 · 241 阅读 · 0 评论 -
Kabaleo Lite
链接:https://ac.nowcoder.com/acm/contest/5673/K来源:牛客网题目描述Tired of boring WFH (work from home), Apollo decided to open a fast food restaurant, called Kabaleo Lite\textbf{Kabaleo Lite}Kabaleo Lite.The restaurant serves nnn kinds of food, numbered原创 2020-08-07 16:05:30 · 275 阅读 · 0 评论 -
Ancient Distance
链接:https://ac.nowcoder.com/acm/contest/5669/A来源:牛客网题目描述As a member of Coffee Chicken, ZYB is a boy with excellent data structure skills.Consider the following problem: Give a rooted tree with N{N}N vertices. Vertices are numbered from 1{1}1 to N{N}N, a原创 2020-08-01 07:55:32 · 276 阅读 · 0 评论 -
Educational Codeforces Round 81 (Rated for Div. 2) E. Permutation Separation
You are given a permutation p1,p2,…,pnp_1,p_2,…,p_np1,p2,…,pn (an array where each integer from 1 to n appears exactly once). The weight of the i-th element of this permutation is ai.At first, you separate your permutation into two non-empty sets — pre原创 2020-05-22 13:05:46 · 337 阅读 · 0 评论 -
MEX maximizing
Recall that MEX of an array is a minimum non-negative integer that does not belong to the array. Examples:for the array [0,0,1,0,2][0,0,1,0,2][0,0,1,0,2] MEX equals to 3 because numbers 0,1 and 2 are presented in the array and 3 is the minimum non-negativ原创 2020-05-20 20:46:45 · 207 阅读 · 0 评论