题目链接:hdu_5813_Elegant Construction 题意: 给你n个点,每个点要可以到达ai个点,可以直接可以间接,不能有环,问是否可行,如果可行就任选一种方式连接,并输出连接的边数和边 题解: 我们按每个点要能到达的点数从小到大排序,然后枚举每个点i,对前面的j(j<i)连一条边,这样保证能到达ai个点,如果第i个点大于等于i,那么肯定没有方案,此时不能向后面的点连边,如果连了就成环了. #include<bits/stdc++.h> using namespace…
C. Drazil and Park 题目连接: http://codeforces.com/contest/516/problem/C Description Drazil is a monkey. He lives in a circular park. There are n trees around the park. The distance between the i-th tree and (i + 1)-st trees is di, the distance between t…