Hidden Hierarchy 题目链接 题目描述 You are working on the user interface for a simple text-based file explorer. One of your tasks is to build a navigation pane displaying the directory hierarchy. As usual, the filesystem consists of directories which may con…
题意:给定N,M,然后给出M组信息(u,v,l,r),表示u到v有[l,r]范围的通行证有效.问有多少种通行证可以使得1和N连通. 思路:和bzoj魔法森林有点像,LCT维护最小生成树. 开始和队友在想维护连通性,而不是维护树,这样好像会很麻烦. 队友yy了一个算法:用线段树模拟并查集维护连通性.(发现和标程有点像? 我的代码:LCT维护最小生成树. ...先给代码,后面补一下题解. #include<bits/stdc++.h> #define ll long long using nam…
用主席树写起来跑的快一点,而且也很傻比,二分答案,即二分那个半径就行 主席树求的是区间<=k的个数 #include<bits/stdc++.h> using namespace std; #define maxn 1000005 int a[maxn],n,m; ]; int rt[maxn],tot; int update(int last,int l,int r,int pos){ int now=++tot; t[now]=t[last]; t[now].v++; if(l==r…
H. Milestones Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100114 Description The longest road of the Fairy Kingdom has n milestones. A long-established tradition defines a specific color for milestones in each region, with a…
链接:https://www.icpc.camp/contests/4mYguiUR8k0GKE H. Highway The input contains zero or more test cases and is terminated by end-of-file. For each test case: The first line contains an integer n. The i-th of the following (n − 1) lines contains three…
E. Correct Bracket Sequence Editor Recently Polycarp started to develop a text editor that works only with correct bracket sequences (abbreviated as CBS). Note that a bracket sequence is correct if it is possible to get a correct mathematical expre…
Buy Tickets Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=2795 Description Railway tickets were difficult to buy around the Lunar New Year in China, so we must get up early and join a long queue… The Lunar New…
http://codeforces.com/contest/725/problem/C Each English letter occurs at least once in s. 注意到题目有这样一句话,那么就是说S中只有一个重复的字母.一定要看到这句话,不然做不了. 然后就找到pos1和pos2分别代表那两个字母的位置,把他们中间的所有字母对折一下,放在最右边就可以了.因为这样才能用上同一个位置. 只有连续两个相同的字母才会impossible,同样是因为只有两个相同的字母. #includ…