Find the answer Time Limit: 4000/4000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 0 Accepted Submission(s): 0 Problem Description Given a sequence of n integers called W and an integer m. For each i (1 <= i <= n),…
线段树分治. 把size看成时间,相当于时间 $l$ 加入这条边,时间 $r+1$ 删除这条边. 注意把左右端点的关系. #include <bits/stdc++.h> ; int X[N], Y[N], top; struct DSU { int fa[N], sz[N]; int find(int x) { while (x != fa[x]) x = fa[x]; return x; } void merge(int x, int y) { x = find(x), y = find(…
由于每个元素贡献是线性的,那么等价于求每个元素出现在多少个异或和为$0$的子集内.因为是任意元素可以去异或,那么自然想到线性基.先对整个集合A求一遍线性基,设为$R$,假设$R$中元素个数为$r$,那么任取一个不在$R$内的元素,$R$中肯定存在一种取法能和这个元素异或和为$0$.同理,取定一个不在$R$内的元素,再随便取另外任意个不在$R$内的元素,$R$内仍然存在一种取法使得这个异或和为$0$.那么每个不在$R$内的元素包含在$2^{n - r - 1}$个集合内(其他不在$R$内的元素可以…
2019 Multi-University Training Contest 8 C. Acesrc and Good Numbers 题意 \(f(d,n)\) 表示 1 到 n 中,d 出现的次数.求小于等于 x 的最大的 \(n\) 满足 \(f(d,n)=n\). 做法 令 \(g(d,n)=f(d,n)-f(n)\),我们要求小于等于 \(x\) 极大的零点. 注意到 \(n>10^{12}\) 一定不存在零点. [比赛时注意到了这点] Big-Small 战法. 取 B 等于 \(1…
2019 Multi-University Training Contest 7 A. A + B = C 题意 给出 \(a,b,c\) 解方程 \(a10^x+b10^y=c10^z\). trick hash! B.Bracket Sequences on Tree unsolved 做法 树hash,统计答案 然后疯狂wa,直到特判了最后两组数据... 假的AC F. Final Exam upsolved 题意 参加考试,确保通过 \(k\) 道题目. 复盘 先是认定了,所有题都复习相…
2019 Multi-University Training Contest 1 A. Blank upsolved by F0_0H 题意 给序列染色,使得 \([l_i,r_i]\) 区间内恰出现 k 种颜色. 做法 DP,\(dp[i][x][y][z]\) 表示考虑前 \(i\) 个位置,剩下 3 种颜色最后出现的位置为 \(x,y,z\) 的方案数 \((i\geq x \geq y \geq z)\) 复盘 比赛开始就提出了这个做法,但很遗憾,过题效率太低,再加上觉得 \(O(n^4…
2019 Multi-University Training Contest 2 A. Another Chess Problem B. Beauty Of Unimodal Sequence 题意 给一个序列,求下标字典序最小和字典序最大的,先增后减的序列. 解体过程 比赛时首先不知道字典序最小LIS怎么求. 试图枚举分界点.[解体的开始] 公无渡河,公竟渡河? 活鱼在摸鱼,rdc在划水,sdcgvhgj在水深火热. 做法 考虑字典序最小的LIS怎么求? 这是个经典问题,预处理前缀LIS后缀L…
2019 Multi-University Training Contest 5 A. fraction upsolved 题意 输入 \(x,p\),输出最小的 \(b\) 使得 \(bx\%p<b\) 做法 \(bx-py<b\),即 \(b(x-1)<py\),即 \(\frac{b}{y}<\frac{p}{x-1}\) 另一方面,\(bx>py\),即 \(\frac{p}{x}<\frac{b}{y}\) GCD 即可. B. three arrays un…
2019 Multi-University Training Contest 6 http://acm.hdu.edu.cn/contests/contest_show.php?cid=853 1002. Nonsense Time 这题比较神奇...有一个结论是:一个长度为\(n\)的随机排列的最长上升子序列期望长度为\(O(\sqrt n)\). 那么我们考虑倒着删数,每次暴力处理出当前任意一个最长上升子序列,然后删除\(x\)的时候判一下\(x\)在不在当前的序列中,在就重新求一遍,否则不…
2019 Multi-University Training Contest 5 http://acm.hdu.edu.cn/contests/contest_show.php?cid=852 1004. Equation 把所有绝对值的零点排个序,然后解方程就好了. #include<bits/stdc++.h> using namespace std; // #define int long long void read(int &x) { x=0;int f=1;char ch=…
2019 Multi-University Training Contest 4 http://acm.hdu.edu.cn/contests/contest_show.php?cid=851 1001. AND Minimum Spanning Tree 如果\(n\not =2^x-1\)那么答案为\(0\),可以这么构造: 对于\(i\ne 2^x-1\)把\(i\)连向第一个比\(i\)小的\(j\),并且\(i\&j=0\). 否则\(i\)连向\(i+1\),把这两个点绑在一起就好了…
2019 Multi-University Training Contest 3 http://acm.hdu.edu.cn/contests/contest_show.php?cid=850 1004. Distribution of books 考虑二分答案,设当前二分出来的是\(x\). 设\(f_i\)表示前\(i\)个能分成最多的段数,使得每一段和都\(\leqslant x\). 转移显然,枚举一个\(j\),若\(s_i-s_j\leqslant x\)则转移,\(s_i\)表示前…
2019 Multi-University Training Contest 2 http://acm.hdu.edu.cn/contests/contest_show.php?cid=849 1005. Everything Is Generated In Equal Probability 考虑一个随机的排列的逆序对个数,显然对于两个数\(a,b\),他们位置是均匀排布的,也就是说有\(\frac{1}{2}\)的概率成为逆序对,并且是独立的. 所以一个长度为\(n\)的随机排列期望逆序对个…
2019 Multi-University Training Contest 1 http://acm.hdu.edu.cn/contests/contest_show.php?cid=848 1001. Blank 这题我打比赛的时候想到正解了没敢写... 设\(f_{a,b,c,d}\)表示\(\{0,1,2,3\}​\)最后一次出现的位置排序之后的结果,那么每次枚举四种情况转移就好了. 复杂度\(O(Tn^4)\),由于转移的循环除了个\(4!\)的常数所以跑的很快. #include<b…
2019 Multi-University Training Contest 2: 1010 Just Skip The Problem 自闭记 题意 多测.每次给你一个数\(n\),你可以同时问无数次,每次问的是一个数\(y_i\),你会得到的回答是\(x\&y_i\)是否为\(y_i\),问你问的最少的次数的种数\(\%1e6+3\),可以调换顺序 10min 得出数学方法 求\(n!\%1e6+3\). 50min 自闭 5min 写出裸暴力,优化10min,交一发TLE 30min 网上…
题目:http://acm.hdu.edu.cn/showproblem.php?pid=6582 Path Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others)Total Submission(s): 3747    Accepted Submission(s): 1075 Problem Description Years later, Jerry fell in love…
Welcome Party Time Limit: 4000/4000 MS (Java/Others)    Memory Limit: 524288/524288 K (Java/Others)Total Submission(s): 875    Accepted Submission(s): 194 Problem Description The annual welcome party of the Department of Computer Science and Technolo…
Redraw Beautiful Drawings Time Limit: 3000/1500 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Problem Description Alice and Bob are playing together. Alice is crazy about art and she has visited many museums around the world. She has…
任意门:http://acm.hdu.edu.cn/showproblem.php?pid=6319 Problem A. Ascending Rating Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 524288/524288 K (Java/Others)Total Submission(s): 5943    Accepted Submission(s): 2004 Problem Description Before…
tree Time Limit: 8000ms Memory Limit: 262144KB This problem will be judged on HDU. Original ID: 539064-bit integer IO format: %I64d      Java class name: Main   Given a rooted tree(node 1 is the root) with n nodes. The ithnode has a positive value vi…
Area of Mushroom Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 2390    Accepted Submission(s): 578 Problem Description Teacher Mai has a kingdom with the infinite area. He has n students guard…
Differencia Time Limit: 10000/10000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 601    Accepted Submission(s): 173 Problem Description Professor Zhang has two sequences a1,a2,...,an and b1,b2,...,bn. He wants to…
Rigid Frameworks Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 337    Accepted Submission(s): 273 Problem Description Erik Demaine is a Professor in Computer Science at the Massachusetts Insti…
2012 Multi-University Training Contest 9 / hdu4389 打巨表,实为数位dp 还不太懂 先这样放着.. 对于打表,当然我们不能直接打,这里有技巧.我们可以这样:每隔100000我们统计一次,这样在10^9范围内,我们得到10000个数. 然后就很好解决了... 数位dp:http://blog.csdn.net/acdreamers/article/details/9318727 #include<iostream> #include<cst…
2014 Multi-University Training Contest 9#11 Killing MonstersTime Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)Total Submission(s): 562    Accepted Submission(s): 308 Problem Description Kingdom Rush is a popular TD…
2014 Multi-University Training Contest 9#6 Fast Matrix CalculationTime Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)Total Submission(s): 424    Accepted Submission(s): 219 Problem Description One day, Alice and Bob…
8/11 2016 Multi-University Training Contest 1 官方题解 老年选手历险记 最小生成树+线性期望 A Abandoned country(BH) 题意: 1. 求最小生成树 2. 求在某一棵最小生成树任意两点的最小距离的期望值. 思路: 首先题目说了边权值都是不同的,所以最小生成树唯一.那么只要统计出最小生成树的每一条边在“任意两点走经过它“的情况下所贡献的值,发现在一棵树里,一条边所贡献的次数为,sz[v]表示v子树包括节点v的个数.如下图所示,红边所…
8/13 2016 Multi-University Training Contest 2官方题解 数学 A Acperience(CYD)题意: 给定一个向量,求他减去一个  α(>=0)乘以一个值为任意+1或-1的B向量后得到向量,求这个向量膜的最小值思路: 展开式子,当时最小,结果为. 代码: #include <bits/stdc++.h> using namespace std; long long w,a,b,c,a2; long long gcd(long long x,l…
5/11 2016 Multi-University Training Contest 3官方题解 2016年多校训练第三场 老年选手历险记 暴力 A Sqrt Bo(CYD) 题意:问进行多少次开根号向下取整能使给定的值为1,若为5次以上,则输出TAT: 思路: 有5次这个限制,得知值最大为10的11次方左右,存下后运算即可,注意初始值为0时运算的次数是大于5次的,输出TAT: 代码: #include <bits/stdc++.h> using namespace std; char st…
6/12 2016 Multi-University Training Contest 4官方题解 KMP+DP A Another Meaning(CYD) 题意: 给一段字符,同时给定你一个单词,这个单词有双重意思,字符串中可能会有很多这种单词,求这句话的意思总数:hehe. 思路: 可以用kmp算法快速求出串中的单词数量,若单词是分开的,每个单词有两种意思,可以直接相乘,若两个及以上单词在原串中是有交集的,那么数量不是直接相乘,发现这片连在一起的单词数量dp[i]=dp[i-1]+dp[j…