题目描述 Bessie has been playing with strings again. She found that by changing the order of the alphabet she could make some strings come before all the others lexicographically (dictionary ordering). For instance Bessie found that for the strings "omm&…
http://acm.hdu.edu.cn/showproblem.php?pid=3342 Legal or Not Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 5788    Accepted Submission(s): 2678 Problem Description ACM-DIY is a large QQ group w…
Sorting It All Out Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 39602   Accepted: 13944 Description An ascending sorted sequence of distinct values is one in which some form of a less-than operator is used to order the elements from s…
One of my friends is always drunk. So, sometimes I get a bit confused whether he is drunk or not. So, one day I was talking to him, about his drinks! He began to describe his way of drinking. So, let me share his ideas a bit. I am expressing in my wo…
HDU Rank of Tetris 题目:http://acm.hdu.edu.cn/showproblem.php?pid=1811 题意:中文问题就不解释题意了. 这道题其实就是一个拓扑排序判圈,我的博客里面其他几篇拓扑排序判圈的套路一样.但是这道题与他们不同的的是在大小关系里面存在一种 “=”的关系,这就意味的那些序号不同的点,实际上是一个点.共享入度和出度.我们可以通过并查集将他们合并,合成一个点.这里说一下如何判断信息不完全.我们早先在做拓扑排序,多种排列方式的时候,按照字典序输出.…
Almost Acyclic Graph CodeForces - 915D time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output You are given a directed graph consisting of n vertices and m edges (each edge is directed, so it can…
题目链接 Solution 感觉比较巧的题啊... 考虑几点: 可以交换无数次字母表,即字母表可以为任意形态. 对于以其他字符串为前缀的字符串,我们可以直接舍去. 因为此时它所包含的前缀的字典序绝对比它本身小. 需要使得某个字符串 \(S\) 字典序最小,需要讨论两种情况: \(1.\) 与它没有公共前缀的字符串 此时我们即使得 \(S_{1}\) 大于其第一个即可. \(2.\) 与它有公共前缀的字符串 我们令其最长公共前缀的位置为 \(k\) . 那么此时我们即要求,对于任意字符串 \(T\…
[题目]D. Almost Acyclic Graph [题意]给定n个点的有向图(无重边),问能否删除一条边使得全图无环.n<=500,m<=10^5. [算法]拓扑排序 [题解]找到一个简单环,则欲删除的边一定经过该环.尝试环上的每一条边(至多n条边)后再次拓扑排序判断全图是否有环. 拓扑排序后定位到简单环:剩余图是环+环内DAG,DFS过程中将走入死路的点标-1,访问过标1,找到访问过的点就是简单环.换起始点直到找到环为止. 复杂度O(nm). #include<cstdio>…
题目描述 Bessie has been playing with strings again. She found that by changing the order of the alphabet she could make some strings come before all the others lexicographically (dictionary ordering). For instance Bessie found that for the strings "omm&…
题目大意: 给定n个总长不超过m的互不相同的字符串,现在你可以任意指定字符之间的大小关系.问有多少个串可能成为字典序最小的串,并输出这些串.n <= 30,000 , m <= 300,000 题解: 首先我们可以把所有的串插入到Trie树中. 然后我们枚举每个串,判断是否存在可行方案 我们枚举到一个串,那么我们就在Trie树中进行查找 每一次从某一个节点向下走的时候,我们都要保证当前走的这条支路是字典序最小的 也就是这条支路上的字母的字典序小于这个节点上的其他所有支路的字典序 所以我们就成功…