直接进行树链剖分,每次对路径区间内的所有点值+1,线段树进行维护,然后查询线段树的最大值的个数!!! 查询线段树区间最大值个数,可以先维护区间和,在维护区间最值,如果区间和等于区间最值乘以区间长度,那么直接返回长度!!! 清空的时候,直接减去,不要直接重新建树 #include<bits/stdc++.h> #define LL long long #define lson rt<<1 #define rson rt<<1|1 using namespace std;…
目录 Contest Info Solutions B. Counting Inversion C. Divisors of the Divisors of An Integer E. Helping the HR F. Path Intersection G. Techland H. Tile Game J. VAT Man Contest Info Practice Link Solved A B C D E F G H I J 7/10 - O O - O O O Ø - O O 在比赛中…
题意:求\(n!\)的每个因子的因子数. 题解:我们可以对\(n!\)进行质因数分解,这里可以直接用推论快速求出:https://5ab-juruo.blog.luogu.org/solution-p2043, 所以我们可以得到\(n!=p^{k1}_1*p^{k_2}_2*...*p^{k_n}_n\),然后根据约数定理,它的任意一个因子可以表示为\(n!=p^{a1}_1*p^{a_2}_2*...*p^{a_n}_n\ (0\le a_i\le k_i)\),我们将某一个质数\(p^{a_…
题意:给出棵树上的k条路径,求这些路径的公共点数量. 将每条路径上的点都打上标记,被标记过k次的点就是公共点了.由于公共点形成的区间是连续的,因此直接在线段树上暴搜即可在$O(logn)$求出一条链上公共点的数量. 怎样找被标记过k次的点呢?可以维护一个区间最大值mx和一个区间最小值mi,如果mx=mi=k说明这一段区间上的点全都为公共点. 清除标记加个线段树区间赋值即可(也可以把标记过的路径一条一条去掉) #include<bits/stdc++.h> using namespace std…
2018-2019 ACM-ICPC, Asia Xuzhou Regional Contest- H. Rikka with A Long Colour Palette -思维+贪心 [Problem Description] 有\(k\)种颜色,给你\(n\)个区间段,选择一种合适的方案给每个区间段染色,使得最终染色次数等于\(k\)次的长度和最大. [Solution] 将左右端点放在一起排序,但是标记出它是左端点,还是右端点,并且记录每个端点属于第几个区间,排序后,对于每个左端点,从未使…
https://codeforces.com/gym/101981 Problem A. Adrien and Austin 贪心,注意细节 f[x]=1:先手必赢. f[x]: 分成两部分(或一部分),长度分别为a和b,只要存在f[a] xor f[b]=0,则f[x]=1. #include <bits/stdc++.h> using namespace std; #define ll long long #define minv 1e-6 #define inf 1e9 #define…
题目链接:https://codeforces.com/gym/102028/problem/C Lewis likes playing chess. Now he has n rooks on the chessboard with $n$ rows and $n$ columns. All rows of the chessboard are labelled with $1$ through $n$ from top to bottom. All columns of the chessb…
题目链接:http://codeforces.com/gym/101981/attachments There are n heroes and m monsters living in an island. The monsters became very vicious these days,so the heroes decided to diminish the monsters in the island. However, the i-th hero can only kill on…
A. Rikka with Minimum Spanning Trees 题意: 给出一个图,求最小生成树的个数和权值 思路: 因为数据随机,只有一个MST #include <bits/stdc++.h> using namespace std; #define ull unsigned long long ull k1, k2; ; int t, n, m; ull f() { ull k3 = k1, k4 = k2; k1 = k4; k3 ^= k3 << ; k2 =…
目录 Contest Info Solutions A. Xu Xiake in Henan Province D. Keiichi Tsuchiya the Drift King E. Resistors in Parallel F. Honeycomb H. Can You Solve the Harder Problem? I. Distance K. Counting Failures on a Trie Contest Info Practice Link Solved A B C D…