随笔分类 - ACM-线段树
摘要:题目: 给定一棵树, 带边权。 现在有2种操作: 1.修改第i条边的权值。 2.询问u到其他一个任意点的最大距离是多少。 题解: 树的直径可以通过两次 dfs() 的方法求得。换句话说,到任意点最远的点,一定是直径的某个端点(反证法)。 • 因此原问题转化为动态维护直径,然后再支持询问两个点的距离,
阅读全文
摘要:Max Mex 题目地址:https://codeforces.com/contest/1084/problem/F Max Mex 然后合并时注意分情况讨论: 参考代码: 1 #include<bits/stdc++.h> 2 using namespace std; 3 #define pb p
阅读全文
摘要:3065: 带插入区间K小值 Description 从前有n只跳蚤排成一行做早操,每只跳蚤都有自己的一个弹跳力a[i]。跳蚤国王看着这些跳蚤国欣欣向荣的情景,感到非常高兴。这时跳蚤国王决定理性愉悦一下,查询区间k小值。他每次向它的随从伏特提出这样的问题: 从左往右第x个到第y个跳蚤中,a[i]第k
阅读全文
摘要:3064: Tyvj 1518 CPU监控 Description Bob需要一个程序来监视CPU使用率。这是一个很繁琐的过程,为了让问题更加简单,Bob会慢慢列出今天会在用计算机时做什么事。 Bob会干很多事,除了跑暴力程序看视频之外,还会做出去玩玩和用鼠标乱点之类的事,甚至会一脚踢掉电源……这些
阅读全文
摘要:维护一个序列,要求支持下列2种操作: add a b c:区间[a,b]中每个数加上c count a b:查询区间[a,b]中有多少数是k的倍数(k为给定常数) 维护一个序列,要求支持下列2种操作: add a b c:区间[a,b]中每个数加上c count a b:查询区间[a,b]中有多少数
阅读全文
摘要:给你N个数,有两种操作 1:给区间[a,b]内的所有数都增加X 2:询问区间[a,b]能被7整除的个数 输入描述 Input Description 第一行一个正整数n,接下来n行n个整数,再接下来一个正整数Q,表示操作的个数. 接下来Q行每行若干个整数。如果第一个数是add,后接3个正整数a,b,
阅读全文
摘要:有n个数和5种操作 add a b c:把区间[a,b]内的所有数都增加c set a b c:把区间[a,b]内的所有数都设为c sum a b:查询区间[a,b]的区间和 max a b:查询区间[a,b]的最大值 min a b:查询区间[a,b]的最小值 有n个数和5种操作 add a b
阅读全文
摘要:小L正在组织acm暑假集训,但众所周知,暑假集训的萌新中有OI神犇,也有暑假才开始学算法的萌新,如果统一集训的难度,无法很好地让萌新们得到训练,所以小L想了一个办法,根据每次测试的情况,改变萌新们的集训难度。现在将萌新们编号为1到n,最初萌新们的集训难度为v0,测试后有两种操作,第一种是某一区间的萌
阅读全文
摘要:题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6356 Glad You Game Steve has an integer array aa of length nn (1-based). He assigned all the elements a
阅读全文
摘要:题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6315 In a galaxy far, far away, there are two integer sequence a and b of length n. b is a static permu
阅读全文
摘要:You are given an array aa consisting of nn integers, and qq queries to it. ii-th query is denoted by two integers lili and riri. For each query, you h
阅读全文
摘要:The citizens of Bytetown, AB, could not stand that the candidates in the mayoral election campaign have been placing their electoral posters at all pl
阅读全文
摘要:The citizens of Bytetown, AB, could not stand that the candidates in the mayoral election campaign have been placing their electoral p...
阅读全文
摘要:In the game of DotA, Pudge’s meat hook is actually the most horrible thing for most of the heroes. The hook is made up of several cons...
阅读全文
摘要:Chinese always have the railway tickets problem because of its' huge amount of passangers and stations. Now goverment need you to deve...
阅读全文
摘要:C国的死对头A国这段时间正在进行军事演习,所以C国间谍头子Derek和他手下Tidy又开始忙乎了。A国在海岸线沿直线布置了N个工兵营地,Derek和Tidy的任务就是要监视这些工兵营地的活动情况。由于采取了某种先进的监测手段,所以每个工兵营地的人数C国都掌握的一清二楚...
阅读全文
摘要:You have N integers, A1, A2, ... , AN. You need to deal with two kinds of operations. One type of operation is to add some given numbe...
阅读全文