///已知各点的度,推断是否为一个简单图 #include<stdio.h> #include<algorithm> #include<string.h> using namespace std; int a[1010]; bool cmp(int x,int y) { return x>y; } int main() { int t,n,i,j; scanf("%d",&t); while(t--) { int flag=1; sca…
题意 给你一个度序列,问能否构成一个简单图. 分析 对于可图化,只要满足度数之和是偶数,即满足握手定理. 对于可简单图化,就是Heavel定理了. Heavel定理:把度序列排成不增序,即 $deg[1] \geq deg[2] \geq ... \geq deg[V]$,则 $deg$ 可简单图化当且仅当 ${deg}' = \{deg[2]-1, deg[3]-1,...,deg[deg[1]+1]-1,...,deg[v] \}$ 可简单图化. 简单地说,把 $deg$ 从大到小排序后,找…
主题链接:pid=2454">http://acm.hdu.edu.cn/showproblem.php?pid=2454 Problem Description Wang Haiyang is a strong and optimistic Chinese youngster. Although born and brought up in the northern inland city Harbin, he has deep love and yearns for the bound…
传送门 参考资料: [1]:图论-度序列可图性判断(Havel-Hakimi定理) •题意 给你 n 个非负整数列,判断这个序列是否为可简单图化的: •知识支持 握手定理:在任何无向图中,所有顶点的度数之和等于边数的2倍: 推论:任何图,奇度顶点的个数为偶数: 可图化定理:非负整数序列 $d={d_1,d_2,\cdots,d_n}$ 是可图化的当且仅当 $\sum_{i=1}^{i \leq n}d_i$ 为偶数: 简单图:既不含平行边,也不含环: 平行边:在无向图中,如果关联一对顶点的无向边…
传送门 •Havel-Hakimi定理: 给定一个非负整数序列{d1,d2,...dn},若存在一个无向图使得图中各点的度与此序列一一对应,则称此序列可图化. 进一步,若图为简单图,则称此序列可简单图化. 定理描述: 由非负整数组成的有限非递增序列,S={d1,d2,d3...dn},当且仅当S1={d2-1,d3-1...d(d1+1),d(d1+2)......dn}也是可图的, 也就是说,序列S1也是由非负整数组成的有限非递增序列,S1是由S的删除第一个元素d1之后的前d1个元素分别减一后…
Problem Description Wang Haiyang is a strong and optimistic Chinese youngster. Although born and brought up in the northern inland city Harbin, he has deep love and yearns for the boundless oceans. After graduation, he came to a coastal city and got…
[题目链接] http://acm.hdu.edu.cn/showproblem.php?pid=2454 [别人博客粘贴过来的] 博客地址:https://www.cnblogs.com/debugcool/archive/2011/04/23/HDOJ2454.html 一句话,顶点的度序列 Havel 定理~ 定义:给出一个无向图的顶点度序列 {dn},要求判断能否构造出一个简单无向图. 分析: 贪心的方法是每次把顶点按度大小从大到小排序,取出度最大的点Vi,依次和度较大的那些顶点Vj连接…
HDU 1560 DNA sequence(DNA序列) Time Limit: 15000/5000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)   Problem Description - 题目描述 The twenty-first century is a biology-technology developing century. We know that a gene is made of DNA. Th…
/* HDU 6078 - Wavel Sequence [ DP ] | 2017 Multi-University Training Contest 4 题意: 给定 a[N], b[M] 要求满足 a[f(1)]<a[f(2)]>a[f(3)]<a[f(4)]>a[f(5)]<a[f(6)]... b[g(i)] == a[f(i)] f(i) < f(i+1), g(i) < g(i+1) 的子序列 的数目 分析: dp[i][j][0] 表示 以a[i]…
p.MsoNormal { margin: 0pt; margin-bottom: .0001pt; text-align: justify; font-family: Calibri; font-size: 10.5000pt } h1 { margin-top: 5.0000pt; margin-bottom: 5.0000pt; text-align: center; font-family: 宋体; color: rgb(26,92,200); font-weight: bold; fo…
HDU 1711 Number Sequence(数列) Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) [Description] [题目描述] Given two sequences of numbers : a[1], a[2], ...... , a[N], and b[1], b[2], ...... , b[M] (1 <= M <= 10000, 1 <= N…
HDU 1005 Number Sequence(数列) Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) [Description] [题目描述] A number sequence is defined as follows: f(1) = 1, f(2) = 1, f(n) = (A * f(n - 1) + B * f(n - 2)) mod 7. Given A, B, an…
HDU 5957 Query on a graph 2016ACM/ICPC亚洲区沈阳站 题意 \(N(N \le 10^5)\)个点,\(N\)条边的连通图. 有\(M \le 10^5\)操作: \(MODIFY\ u\ k\ d,k \le 2\):距离点\(u\)不超过\(k\)的点的权值都加上\(d\). \(QUERY\ u\ k\):询问距离\(d\)不超过\(k\)的点权和. 思路 图的形状时一个环和若干树枝构成. 考虑\(k=1\)时,分两种情况讨论: \(u\)在环上,则需要…
HDU 5860 Death Sequence(递推) 题目链接http://acm.split.hdu.edu.cn/showproblem.php?pid=5860 Description You may heard of the Joseph Problem, the story comes from a Jewish historian living in 1st century. He and his 40 comrade soldiers were trapped in a cave…
HDU 1005 Number Sequence(数论) Problem Description: A number sequence is defined as follows:f(1) = 1, f(2) = 1, f(n) = (A * f(n - 1) + B * f(n - 2)) mod 7. Given A, B, and n, you are to calculate the value of f(n).   Input The input consists of multipl…
HDU 1711 Number Sequence (字符串匹配,KMP算法) Description Given two sequences of numbers : a1, a2, ...... , aN, and b1, b2, ...... , bM (1 <= M <= 10000, 1 <= N <= 1000000). Your task is to find a number K which make aK = b1, aK+1 = b2, ...... , aK+M…
/* HDU 6047 - Maximum Sequence [ 单调队列 ] 题意: 起初给出n个元素的数列 A[N], B[N] 对于 A[]的第N+K个元素,从B[N]中找出一个元素B[i],在 A[] 中找到一个数字A[p]满足 B[i] <= p <= N+K-1 令 A[N+K] = A[p]-p,直到A[]的长度等于2N 问 A[N+1] + A[N+2] + ... + A[N<<1] 最大是多少 分析: 将A[]中元素全部减去其下标 将B[]排序,可分析一定是从小…
HDU - 1005 Number Sequence Problem Description A number sequence is defined as follows:f(1) = 1, f(2) = 1, f(n) = (A * f(n - 1) + B * f(n - 2)) mod 7.Given A, B, and n, you are to calculate the value of f(n). Input The input consists of multiple test…
http://acm.hdu.edu.cn/showproblem.php?pid=1560 DNA sequence Time Limit: 15000/5000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 732    Accepted Submission(s): 356 Problem Description The twenty-first century is a…
DNA sequence Time Limit : 15000/5000ms (Java/Other)   Memory Limit : 32768/32768K (Java/Other) Total Submission(s) : 15   Accepted Submission(s) : 7 Font: Times New Roman | Verdana | Georgia Font Size: ← → Problem Description The twenty-first century…
http://acm.hdu.edu.cn/showproblem.php?pid=1560 仔细读题(!),则可发现这道题要求的是一个最短的字符串,该字符串的不连续子序列中包含题目所给的所有字符串 因为总共只有40个字符,可以尝试使用A*搜索 1.存储状态时直接存储40个字符,每个字符4种可能是肯定不行的. 因为要求的是包含不连续的子序列,所以只需记住当前字符串长度与每个子序列已经包含在当前字符串的长度, 比如题目中的输入样例 4 ACGT ATGC CGTT CAGT 可以这样存储一个序列…
http://acm.hdu.edu.cn/showproblem.php?pid=5400 Arithmetic Sequence Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 1151    Accepted Submission(s): 501 Problem Description A sequence b1,b2,⋯,bn a…
题目地址:http://acm.hdu.edu.cn/showproblem.php?pid=1560 BFS题解:http://www.cnblogs.com/crazyapple/p/3218107.html 构造一个串,使得它包含所有的给定DNA序列,并且要求长度最短.采用dfs策略,对于每个串定义1个指针,当全部指针为串尾时判断构造的长度,由于状态空间过大,但是又存在冗余搜索,可以用迭代加深将状态减少.最长待构造长度 + 当前长度 < 迭代的最大深度则直接return,大大减少了状态数.…
http://acm.hdu.edu.cn/showproblem.php?pid=2817 __int64 pow_mod (__int64 a, __int64 n, __int64 m)快速幂取模函数. A sequence of numbers Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 4047    Accepted Su…
A new Graph Game Problem Description An undirected graph is a graph in which the nodes are connected by undirected arcs. An undirected arc is an edge that has no arrow. Both ends of an undirected arc are equivalent--there is no head or tail. Therefor…
Recursive sequence Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 249    Accepted Submission(s): 140 Problem Description Farmer John likes to play mathematics games with his N cows. Recently, t…
Parenthese sequence                                                                     Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others) Problem Description bobo found an ancient string. The string contains only t…
题目网址:http://acm.hdu.edu.cn/showproblem.php?pid=6047 题目: Maximum Sequence Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 90    Accepted Submission(s): 44 Problem Description Steph is extremely o…
Number Sequence Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 175657    Accepted Submission(s): 43409 Problem Description A number sequence is defined as follows: f(1) = 1, f(2) = 1, f(n) = (A…
Number Sequence Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 27028    Accepted Submission(s): 11408 Problem Description Given two sequences of numbers : a[1], a[2], ...... , a[N], and b[1],…