
数据结构
ZzzzGgggHhhh
这个作者很懒,什么都没留下…
展开
-
leetcode——715. Range 模块
题目链接线段树加动态开点const int N=1e6+500;const int M=1e9;struct tree { int l,r; int data,lazy;#define l(p) t[p].l#define r(p) t[p].r#define data(p) t[p].data#define lazy(p) t[p].lazy} t[N];class RangeModule { public: int tot,root; RangeModule() {原创 2021-01-02 20:54:48 · 208 阅读 · 0 评论 -
2020CCPC绵阳站——J
Joy of Handcraft题意:一串灯泡,每个灯泡都有一个亮度,一个开关周期,问每秒最亮的灯度是多少。题解:相同开关周期的灯泡,同时关,同时开,所以同一周期的灯泡,只需要考虑亮度最高的那个即可,其余灯泡对答案没影响。每一秒过后,周期为该秒数的因子的灯会变换一次状态,1e5以内的数,最多有120+个因子,所以,每秒最多只需要修改120+个等的状态即可。我们可以用线段树维护每种周期灯的状态,节点维护区间最大值,每次查询答案,只需要看根节点的值即可。#include<bits/stdc++原创 2020-11-04 21:13:30 · 923 阅读 · 0 评论 -
洛谷——P1456 Monkey King
题目描述Once in a forest, there lived N aggressive monkeys. At the beginning, they each does things in its own way and none of them knows each other. But monkeys can’t avoid quarrelling, and it only happens between two monkeys who does not know each other. An原创 2020-09-19 11:22:07 · 391 阅读 · 0 评论 -
洛谷——P4198 楼房重建
题目描述小 A 的楼房外有一大片施工工地,工地上有 NN 栋待建的楼房。每天,这片工地上的房子拆了又建、建了又拆。他经常无聊地看着窗外发呆,数自己能够看到多少栋房子。为了简化问题,我们考虑这些事件发生在一个二维平面上。小 A 在平面上 (0,0)(0,0) 点的位置,第 ii 栋楼房可以用一条连接 (i,0)(i,0) 和 (i,H_i)(i,Hi ) 的线段表示,其中 H_iHi 为第 ii 栋楼房的高度。如果这栋楼房上任何一个高度大于 00 的点与 (0,0)(0,0) 的连线没有与原创 2020-09-14 22:14:43 · 257 阅读 · 0 评论 -
CF——501D(变进制数康托展开)
D. Misha and Permutations Summationtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputLet’s define the sum of two permutations p and q of numbers 0, 1, …, (n - 1) as permutation , where Perm(x) is the原创 2020-08-23 18:20:17 · 175 阅读 · 0 评论 -
2020牛客暑期多校训练营(第八场)—— K
Kabaleo Lite链接:https://ac.nowcoder.com/acm/contest/5673/K来源:牛客网时间限制:C/C++ 1秒,其他语言2秒空间限制:C/C++ 262144K,其他语言524288K64bit IO Format: %lld题目描述Tired of boring WFH (work from home), Apollo decided to open a fast food restaurant, called \textbf{Kabaleo Lit原创 2020-08-05 22:42:32 · 324 阅读 · 0 评论 -
二维线段树
二维数组,稍微学了一下,写个博客,留个板子,日后忘了看。HDU——4819#include<bits/stdc++.h>using namespace std;typedef long long ll;const int N=1005;int maxx[N*4][N*4],minn[N*4][N*4],a[N][N];int n,m,Mx,Mi;void pushup(int px,int py) { maxx[px][py]=max(maxx[px][py*2],maxx[p原创 2020-07-26 00:03:31 · 248 阅读 · 1 评论 -
2020牛客暑期多校训练营(第二场)——H
Happy Triangle链接:https://ac.nowcoder.com/acm/contest/5667/H来源:牛客网时间限制:C/C++ 2秒,其他语言4秒空间限制:C/C++ 262144K,其他语言524288K64bit IO Format: %lld题目描述Given a multiset {MS}MS and {q}q operations. {MS}MS is empty initailly, and operations are in three types, wh原创 2020-07-14 22:55:03 · 288 阅读 · 0 评论 -
牛客算法周周练15——D
树上求和链接:https://ac.nowcoder.com/acm/contest/6290/D来源:牛客网时间限制:C/C++ 1秒,其他语言2秒空间限制:C/C++ 262144K,其他语言524288K64bit IO Format: %lld题目描述给你一棵根为1的有N个节点的树,以及Q次操作。每次操作诸如:1 x y:将节点x所在的子树的所有节点的权值加上y2 x:询问x所在子树的所有节点的权值的平方和,答案模23333后输出输入描述:第一行两个整数N,Q第二行N个整数原创 2020-07-14 21:49:43 · 283 阅读 · 0 评论 -
2019南昌邀请赛-F
F - SequenceOldjang has a sequence A of length n , the i t h number in which is A i . He defined a function f ( l , r ) = a l ⊕ a l + 1 ⊕ ⋯ ⊕ a r . It is simple for the cleverest boy oldjang to calculate the function, so he wants to make the problem more原创 2020-07-08 18:01:36 · 202 阅读 · 0 评论 -
第三届中国计量大学ACM程序设计竞赛个人赛(同步赛)——L
链接:https://ac.nowcoder.com/acm/contest/5795/L来源:牛客网题目描述One day, Little Gyro was playing with a series of Bracket Sequences, A Bracket Sequence is a string that only contains two kinds of characters ‘(’ and ‘)’. Let us define a regular Bracket Sequence i原创 2020-06-03 22:41:34 · 494 阅读 · 0 评论 -
ST表
ST表入门ST表类似树状数组,线段树这两种算法,是一种用于解决RMQ(Range Minimum/Maximum Query,即区间最值查询)问题的离线算法与线段树相比,预处理复杂度同为O(nlogn),查询时间上,ST表为O(1),线段树为O(nlogn)贴一道模板题洛谷:https://www.luogu.com.cn/problem/P3865板子:#include<bi...原创 2020-03-03 19:24:38 · 138 阅读 · 0 评论 -
AcWing-244.谜一样的牛
题解:从后往前依次判断牛的高度,当前牛之前有a个牛比它低,则当前牛的最低身高为a+1,所以当前牛的高度为所有牛的第a+1低,然后二分判断当前所有牛中第a+1,低的牛身高为多少,当前每头牛被选走之后,记录一下。用树状数组维护牛身高的序列,前缀和求第几高,当牛被选走之后,该身高位置减一即可。#include<stdio.h>#include<algorithm>us...原创 2020-01-04 19:59:59 · 285 阅读 · 0 评论 -
牛客练习赛56-C
C 小魂和他的数列题解还没太想明白,想明明白白了再写#include<stdio.h>#include<algorithm>using namespace std;typedef long long ll;const int N=600500;const ll mod=998244353;ll c[N][15],ans[N][15];int a[N],b[...原创 2019-12-28 11:49:47 · 275 阅读 · 0 评论 -
CodeForces - 1227D2(树状数组)
D2. Optimal Subsequences (Hard Version)This is the harder version of the problem. In this version, 1≤n,m≤2⋅105. You can hack this problem if you locked it. But you can hack the previous problem only ...原创 2019-12-27 17:53:05 · 309 阅读 · 0 评论 -
[SHOI2009]会场预约(洛谷)
解法1:树状数组对于每一个A,二分查找结束时间ed以内的最大的其余会议的起始时间,如果该会议的结束时间大于当前会议的结束时间,则冲突了,即可删掉该会议。树状数组中维护了会议的起始时间,对于每一次删除只需要进行单点更新即可。#include<stdio.h>#include<algorithm>using namespace std;const int N=2...原创 2019-12-26 22:20:56 · 154 阅读 · 0 评论 -
牛客小白月赛20-E(线段树)
E-区区区间#include<stdio.h>#include<algorithm>using namespace std;typedef long long ll;const int N=2e5+5;ll a[N];struct Tree { int l,r; ll dat,lazy;} t[N*4];void build(int p,int l,...原创 2019-12-22 21:14:58 · 221 阅读 · 0 评论 -
P1972 [SDOI2009]HH的项链(洛谷)
P1972 [SDOI2009]HH的项链离线树状数组#include<stdio.h>#include<algorithm>using namespace std;const int N=1e6+500;int n,m;int a[N],pos[N],c[N],ans[N];struct node { int l,r,id; friend bool ...原创 2019-12-22 17:03:43 · 149 阅读 · 0 评论