ST算法Code: //#include<bits/stdc++.h> #include<cstdio> #include<math.h> #include<iostream> #include<queue> #include<algorithm> #include<string.h> using namespace std; typedef long long LL; const int N=5e4+10; int n,…
D. Mike and Feet time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Mike is the president of country What-The-Fatherland. There are n bears living in this country besides Mike. All of them are…
原题地址 终于做到线段树的题了,因为建树.更新.查询都是递归操作,所以其实挺好写的. 用数组存的树,记得MAX_NODE开成两倍叶节点数大小,否则RE啊..不要问我是怎么知道的. 代码: #include <iostream> #include <climits> using namespace std; #define MAX_NODE 2000008 int N, Q; struct SegmentTree { int left[MAX_NODE]; int right[MAX…
Mex Time Limit: 15000/5000 MS (Java/Others) Memory Limit: 65535/65535 K (Java/Others)Total Submission(s): 623 Accepted Submission(s): 209 Problem Description Mex is a function on a set of integers, which is universally used for impartial game t…
题目链接 一个数被开方 #include<bits/stdc++.h> #define setIO(s) freopen(s".in","r",stdin),freopen(s".out","w",stdout) #define maxn 300003 #define ll long long using namespace std; int n,m; ll mx[maxn<<2],mn[maxn<…
题目链接 In the traditional RMQ (Range Minimum Query) problem, we have a static array A. Then for each query (L, R)(L \leR), we report the minimum value among A[L], A[L + 1], ..., A[R]. Note that the indices start from 1, i.e. the left-most element is A[…
RMQ with Shifts 时间限制:1000 ms | 内存限制:65535 KB 难度:3 描述 In the traditional RMQ (Range Minimum Query) problem, we have a static array A. Then for each query (L, R) (L<=R), we report the minimum value among A[L], A[L+1], …, A[R]. Note that the ind…
链接:https://www.nowcoder.com/acm/contest/105/H来源:牛客网 n个桶按顺序排列,我们用1~n给桶标号.有两种操作: 1 l r c 区间[l,r]中的每个桶中都放入一个颜色为c的球 (1≤l,r ≤n,l≤r,0≤c≤60) 2 l r 查询区间[l,r]的桶中有多少种不同颜色的球 (1≤l,r ≤n,l≤r) 输入描述: 有多组数据,对于每组数据:第一行有两个整数n,m(1≤n,m≤100000)接下来m行,代表m个操作,格式如题目所示.…