随笔分类 - OJ---HDU
摘要:题意:给定A,B长度相同的字符串,Q次操作,修改操作位单个字符修改,查询操作为询问从某点开始有多少连续相同的字符。 思路:我们把不相同的设为1,相同的设为0,那么询问就是找下一个为1的为位置,可以用线段树解决,可以用set的lower_bound解决,这里用bitset的Find_next函数,效率
阅读全文
摘要:题意:给定N个组合,每个组合有a和b,现在求最长序列,满足a不升,b不降。 思路:三位偏序,CDQ分治。 但是没想到怎么输出最小字典序,我好菜啊。 最小字典序: 我们倒序CDQ分治,ans[i]表示倒序的以i为结尾的最长序列,如果当前的ans[i]==目前最大,而且满足序列要求,就输出。
阅读全文
摘要:Given you a sequence of number a 1, a 2, ..., a n, which is a permutation of 1...n. You need to answer some queries, each with the following format: G
阅读全文
摘要:In graph theory, the complement of a graph G is a graph H on the same vertices such that two distinct vertices of H are adjacent if and only if they a
阅读全文
摘要:Jimmy experiences a lot of stress at work these days, especially since his accident made working difficult. To relax after a hard day, he likes to wal
阅读全文
摘要:The math department has been having problems lately. Due to immense amount of unsolicited automated programs which were crawling across their pages, t
阅读全文
摘要:题意:T组数据,给次给出N,M,K,多少种方案,用[0,N-1]范围的数,表示一个M排列,其和为K; 思路:隔板法,不限制[0,N-1]的时候答案是C(M+K-1,M-1);那么我们减去至少一个>=N,加上至少两个>=N....即可得到答案。 假设至少一个隔板里的数大于大于N,我们从这个隔板里抽出N
阅读全文
摘要:一个包含四个点的完全图,可以在任意节点出发,可以在任意节点结束,给出每个点被经过的次数,求有多少种合法的遍历序列。如果两个序列至少有一位是不同的,则认为它们不相同。 Input Sample Output 题意:给a个A,b个B,c个C,d个D,求有少种排列,使得相邻的两个不同。 思路:用容斥来做,
阅读全文
摘要:There is a connected undirected graph with weights on its edges. It is guaranteed that each edge appears in at most one simple cycle. Assuming that th
阅读全文
摘要:Declare: k=∑ m i=1 φ(i∗n) mod 1000000007 k=∑i=1mφ(i∗n) mod 1000000007 n n is a square-free number. φ φ is the Euler's totient function. find: ans=k k
阅读全文
摘要:There are n n apples on a tree, numbered from 1 1 to n n . Count the number of ways to pick at most m m apples. InputThe first line of the input conta
阅读全文
摘要:Yellowstar likes integers so much that he listed all positive integers in ascending order,but he hates those numbers which can be written as a^b (a, b
阅读全文
摘要:Tom owns a company and he is the boss. There are n staffs which are numbered from 1 to n in this company, and every staff has a ability. Now, Tom is g
阅读全文
摘要:题面太丑了,就不复制了。 题意:F1=A; F2=B; Fn=D*Fn-1+C*Fn-2+P/i;求Fn。 思路:根据P/i的值划分区间,每个区间矩阵求。 带常数的矩阵:
阅读全文
摘要:There are n numbers 3^0, 3^1, . . . , 3^n-1. Each time you can choose a subset of them (may be empty), and then add them up. Count how many numbers ca
阅读全文
摘要:Senior Pan fails in his discrete math exam again. So he asks Master ZKC to give him graph theory problems everyday. The task is simple : ZKC will give
阅读全文
摘要:There is a tree having N vertices. In the tree there are K monkeys (K <= N). A vertex can be occupied by at most one monkey. They want to remove some
阅读全文
摘要:Do you like painting? Little D doesn't like painting, especially messy color paintings. Now Little B is painting. To prevent him from drawing messy pa
阅读全文
摘要:Bob's school has a big playground, boys and girls always play games here after school. To protect boys and girls from getting hurt when playing happil
阅读全文

浙公网安备 33010602011771号