query Given a permutation pp of length nn, you are asked to answer mm queries, each query can be represented as a pair (l ,r )(l,r), you need to find the number of pair(i ,j)(i,j) such that l \le i < j \le rl≤i<j≤r and \min(p_i,p_j) = \gcd(p_i,p_j )…
由于每个元素贡献是线性的,那么等价于求每个元素出现在多少个异或和为$0$的子集内.因为是任意元素可以去异或,那么自然想到线性基.先对整个集合A求一遍线性基,设为$R$,假设$R$中元素个数为$r$,那么任取一个不在$R$内的元素,$R$中肯定存在一种取法能和这个元素异或和为$0$.同理,取定一个不在$R$内的元素,再随便取另外任意个不在$R$内的元素,$R$内仍然存在一种取法使得这个异或和为$0$.那么每个不在$R$内的元素包含在$2^{n - r - 1}$个集合内(其他不在$R$内的元素可以…
D. Events 线段树区间更新查询区间历史最小值,看似很简单的题意写了两天才写出来. 题意:n个数,Q次操作,每次操作对一个区间[l,r]的数同时加上C,然后输出这段区间的历史最小值. 思路:在线段树区间更新最值查询的基础上再用一个变量表示历史最小值,每次更新只需对当前最小值更新然后用当前最小值更新历史最小值.细节问题很不好处理,可能会有重复多次更新某个区间但是其下的子节点叶节点却没有更新,而是每次重复叠加了一个add值,这样就可能将最小值覆盖.所以我们在pushdown操作的时候应该注意如…
Here is a square matrix of n * nn∗n, each lattice has its value (nn must be odd), and the center value is n * nn∗n. Its spiral decline along the center of the square matrix (the way of spiral decline is shown in the following figure:) The grid in the…
原文链接https://www.cnblogs.com/zhouzhendong/p/ARC101D.html 题目传送门 - ARC101D 题意 给定一个序列 A . 定义一个序列 A 的中位数为:给 A 排序,得到的第 $\left\lfloor\cfrac{i}{2}\right\rfloor+1$ 项的值. 序列 B 由序列 A 的所有连续子序列的中位数构成. 问序列 B 的中位数是多少. 序列中可能出现重复的数,$|A| \leq 10^5$ . 题解 注意这里说的“中位数”是题意里…
结论:每次把字符丢到最外面最优,用树状数组统计答案,把字符放到最外边后可以当成消失了,直接在树状数组上删掉就好. 感性理解是把字符丢到中间会增加其他字符的移动次数,但是丢到外面不会,所以是正确的. #include<iostream> #include<cstring> #include<cstdlib> #include<cstdio> #define ll long long using namespace std; ; int n, x, num; ]…
Performance ReviewEmployee performance reviews are a necessary evil in any company. In a performance review, employees give written feedback about each other on the work done recently. This feedback is passed up to their managers which then decide pr…
#include<bits/stdc++.h> using namespace std; typedef long long ll; int n,m; ; struct node { int team; int num; int time; int id; }a[maxn]; int ans[maxn]; int b[maxn]; int c[maxn]; int s[maxn]; int team[maxn]; int tree[maxn]; int pre[maxn]; int lowbi…
I. Yukino With Subinterval 题目链接: Problem Descripe Yukino has an array \(a_1, a_2 \cdots a_n\). As a tsundere girl, Yukino is fond of studying subinterval. Today, she gives you four integers $l, r, x, y $, and she is looking for how many different sub…