图论 SRM 674 Div1 VampireTree 250】的更多相关文章

Problem Statement      You are a genealogist specializing in family trees of vampires. Vampire family trees differ from human family trees. In particular, vampires are "born" in a different way. The only way to create a new vampire is that an ex…
Problem Statement      Cat Noku has just finished writing his first computer program. Noku's computer has m memory cells. The cells have addresses 0 through m-1. Noku's program consists of n instructions. The instructions have mutually independent ef…
Topcoder SRM 643 Div1 250 Problem 给一个整数N,再给一个vector<long long>v; N可以表示成若干个素数的乘积,N=p0*p1*p2*......*pn,我们假设p0,p1,...,pn是单调不降的,那么v里存储的是下标为偶数 的N的质因数p0,p2,p4,...,p(2k).现在要求写一个程序,返回一个vector<long long>ans; ans里存储的是p0,p1,p2,...,pn. Limits Time Limit(m…
Topcoder Srm 726 Div1 Hard 解题思路: 问题可以看做一个二分图,左边一个点向右边一段区间连边,匹配了左边一个点就能获得对应的权值,最大化所得到的权值的和. 然后可以证明一个结论,将点按照权值大小排序后,从大到小加点的充要条件是完美匹配大小 \(+1\) .考虑如果不是按照这种方式加点的,必然能找到一个没有被匹配的点替换掉一个在匹配中但是权值比它小的点,答案一定会变大. 于是我们可以从大到小枚举点,如果能加进去且完美匹配大小增加就加入这个点,否则就不加. solutoin…
挺简单的组合把. #include <cstdio> #include <cstring> #include <iostream> #include <vector> using namespace std; #define LL long long ]; ]; class LittleElephantAndIntervalsDiv1 { public : LL getNumber(int M, vector <int> L, vector &l…
可能开始宿舍比较乱,思绪静不下来...想了大半个小时,终于确定了应该暴力+DP,然后写了枚举除数,和被除的版本..这样,还敲错了个字母,第一次提交还100多,修改提交还有75.多,最后想到,貌似不打对啊,改完再交就剩下75了...还好,没挂0...这样写,还是比较好写的,最后10分钟,开始改,最后4分钟改完.. #include <iostream> #include <cstdio> #include <cstring> #include <vector>…
我只能说的亏没做,要不就挂0了.. 本来想四色定理,肯定4就可以的...然后准备爆,发现3的时候不好爆,又想了老一会,嗯,数据范围不小,应该不是暴力,直接找规律,貌似最大就是3,有一个3连块,输出3,其他输出2什么的.交,发现有环的时候,特殊的也是3...没办法还得暴力啊.暴力2的情况,写的也是各种错误...终于过了. #include <iostream> #include <cstdio> #include <cstring> #include <vector…
这图最多3色就可以 搜2就行了 #include <iostream> #include<cstdio> #include<cstring> #include<stdlib.h> #include<vector> #include<algorithm> #include<string> using namespace std; ][],c[][],f[],mm; ][] = {{,},{,},{-,},{,-},{-,},…
Problem Statement The least common multiple (denoted "lcm") of a non-empty sequence of positive integers is the smallest positive integer that is divisible by each of them. For example, lcm(2)=2, lcm(4,6)=12, and lcm(1,2,3,4,5)=60. Alice had a p…
题意 [题目链接]这怎么发链接啊..... Sol 枚举一个断点,然后类似于LIS一样dp一波 这个边界条件有点迷啊..fst了两遍... #include<bits/stdc++.h> using namespace std; const int MAXN = 1e5 + 10, INF = 1e9 + 7; inline int read() { char c = getchar(); int x = 0, f = 1; while(c < '0' || c > '9') {i…
250 题意:有n首不同的曲子,你唱每首曲子需要花费a的时间以及一个调整的时间b,调整的时间为此首歌的曲调减去上一首歌的曲调的绝对值. 思路:我们用dp[i][k]表示前i首歌只唱k首用的最小时间花费,最后拿所有的dp[i][k]和T做比较,满足条件则选取最大的k.这样的思路是没错的,但是...没注意到一种情况,dp[i][k]只要选了就保证序列定下来了,因为取的是绝对值,序列定下来的说明和时长a没关系,所以这时候要保证abs最小,又因为是从前往后推,所以只有排序后才能保证绝对值最小,有点贪心的…
250pt: 暴力枚举所有的可能的情况就好了,求面积的时候我是用梯形的面积减去两个三角形的面积.. 550pt: 题意:给你一个蜂窝形状的特殊图形,有一些格子已经被占据了,问你将剩下的格子用1*2的砖块尽可能的铺满的总方案数,见下图. 此题想了半天,隐约感觉可以dp,但是无从D起,,,膜拜了下rng_58的超短代码(大部分人选择dfs转移),但是rng_58将图转换成网格后巧妙的使用逐格递推的方法,代码超短,简直就是高端洋气上档次啊,好想又好写,这种题我以前都是dfs写转移的,要,b半天才能写出…
要掉到DVI2了..好不容这次的250那么简单,500的题知道怎么做,可惜没调出来500. 250的题很简单,从第1步到第N步,每次要么不做,要么走i步,且X不能走,问说最远走多远. #include <iostream> #include <vector> #include <string> #include <string.h> using namespace std; class JumpFurther { public: int furthest(i…
最近连续三次TC爆零了,,,我的心好痛. 不知怎么想的,这题把题意理解成,第一次选择j,第二次选择i后,只能从1~i-1.i+1~j找,其实还可以从j+1~n中找,只要没有被选中过就行... [题意] 给出n个蛋糕,第i个蛋糕的宽度是i,每个蛋糕有一个娱乐值d[i],(题目中是从0开始的,我这里暂时视为从1开始)一开始从所有蛋糕中等概率拿出一个蛋糕,设它的宽度为k. 接下来,等概率地从剩余蛋糕中选择,[1]如果选出的蛋糕宽度大于K,则终止选择,[2]如果小于K,则继续以同样的方法等概率地在剩余的…
A 裸最短路. class TravelOnMars { public: int minTimes(vector <int>, int, int); }; vector<int> e[maxn]; int n; int dist(int a,int b) { if (a>b) swap(a,b); int res = min( b-a , a+n-b); return res; } int d[maxn],inq[maxn]; queue<int> q; int…
转载请注明出处,谢谢viewmode=contents">http://blog.csdn.net/ACM_cxlove?viewmode=contents    by---cxlove 水水更健康,最终回到1800+了... DIV2 1000pt 显然每一列是独立的.分开考虑. 对于某一列.假设按单个字符U , D从下往上考虑的话.发现连续两个U的话.以下的U能够移动的位置受上面一个影响. 只是因此能够想到相邻的U , D互相限制位置,能够依次处理.相邻同样字符的话. 能够作为一个字符…
250: 题目大意: 在一个N行无限大的网格图里,每经过一个格子都要付出一定的代价.同一行的每个格子代价相同. 给出起点和终点,求从起点到终点的付出的最少代价. 思路: 最优方案肯定是从起点沿竖直方向走到某一行,然后沿水平方向走到终点那一列,然后再沿竖直方向走到终点那一行. 枚举是通过哪一行的格子从起点那列走到终点那列的,求个最小值就好了. 代码: // BEGIN CUT HERE // END CUT HERE #line 5 "LongMansionDiv1.cpp" #incl…
SRM 717 DIV 1 中 出了这样一道题: 竞赛图就是把一个无向完全图的边定向后得到的有向图,得分序列就是每个点的出度构成的序列. 给出一个合法的竞赛图出度序列, 要求构造出原图(原题是求(u, v)有路径的点对数,似乎有不需要构造出原图的方法). 当时我的做法是 直接构造一个网络,跑最大流. 比赛后总觉得这个题有什么神奇的性质,于是搜了一下相关资料: 有一篇关于得分序列的论文:http://www.sciencedirect.com/science/article/pii/0095895…
题意 [题目链接]这怎么发链接啊..... 有\(n\)张符卡排成一个队列,每张符卡有两个属性,等级\(li\)和伤害\(di\). 你可以做任意次操作,每次操作为以下二者之一: 把队首的符卡移动到队尾. 使用队首的符卡,对敌人造成\(d_i\)点伤害,并丢弃队首的\(l_i\)张符卡(包括你所使用的符卡).如果队列不足\(l_i\)张符卡那么你不能使用. 求出造成的伤害的总和的最大值. \(1<=n<=50, 1<=li<=50, 1<=di<=10000\) Sol…
打卡- Easy(250pts): 题目大意:rating2200及以上和2200以下的颜色是不一样的(我就是属于那个颜色比较菜的),有个人初始rating为X,然后每一场比赛他的rating如果增加就会加D[i],如果减就会减D[i],但是如果rating小于0了就变成0,这个人不太喜欢比较厉害的颜色,所以他不能连续两次rating大于等于2200,求颜色变化的最多个数,保证比赛最多50场,D[i]<=10^9. 这套题还是很难的,所以我们来好好分析. 首先,样例0告诉我们贪心什么都是假的,不…
Problem Statement      Wolf Sothe and Cat Snuke are playing a card game. The game is played with exactly 100 cards. The cards are numbered from 1 to 100. The game is played as follows: First, Cat Snuke chooses the goal: an integer N between 1 and 100…
非常棒的组合问题,看了好一会,无想法.... 有很多做法,我发现不考虑顺序的最好理解,也最好写. 结果一定是两种形式 A....A   dp[n-1] A...A...A sgma(dp[j]*dp[n-j-1])( 1<=j<=n-2) 最后乘上n! 什么时候才能自己在比赛中做出一个500分来啊!!! class LongWordsDiv1 { public : int count(int n) { int i,j; fact[] = ; ; i <= n; i ++) { fact[…
Problem Statement      The purpose of a roundabout is to control the flow of traffic at a busy intersection. A roundabout has 4 entry points: from the North, East, South and West; and 4 exit points at the same locations (see Example 0 for a diagram).…
Problem Statement      Masterbrain is a two player board game in which one player decides on a secret combination of digits, while the other must figure it out in 10 guesses or less. The game differs from Mastermind in that the player making the secr…
Problem Statement      The Happy Letter game is played as follows: At the beginning, several players enter the field. Each player has a lowercase English letter on their back. The game is played in turns. In each turn, you select two players with dif…
body { font-family: Monospaced; font-size: 12pt } pre { font-family: Monospaced; font-size: 12pt } Problem Statement      You have an array with N elements. Initially, each element is 0. You can perform the following operations: Increment operation:…
TC 都615了...时间过的真快啊. 第一次做出500分,心情还是很激动的,虽然看了很久的题解,TC官网上的题解,很详细,但是英语的...我搜了搜,发现一份日语的...好吧,我还是看看英语的吧... 这题算法就是二维spfa啊,很容易看出,存在一个环mod,那么D+x*mod = T 这样话,就合法了.就可以用dis[d][u] u表示点,距离 模mod 为d,这样跑一下spfa,只要dis[T%mod][n-1] <= T(小于T的,可以补mod) 说明合法了. 开始看题解的时候 比较纠结m…
 topcoder被Appirio收购了 好久没做tc,这个题目挺简单.就是Arena里面看不到图片,只能去tc网站上找题目.http://community.topcoder.com/stat?c=problem_statement&pm=12746 #include <vector> #include <list> #include <map> #include <set> #include <queue> #include <…
思路太繁琐了 ,实在不想解释了 代码: #include<iostream> #include<cstdio> #include<string> #include<cstring> #include<cmath> #include<set> #include<map> #include<stack> #include<vector> #include<algorithm> #includ…
题意:有n个等长的string(设string的长度为m),string中的字符从'A'到'Z',容许对m列执行稳定的排序操作,问说是否能通过这m种操作将这n个string调整成对应的顺序. 题解: 为了保证区间[0, n)有序,考虑最后一个操作,该操作使得某一列在区间[0, n)中是有序的,这个操作将这n个序列分成了若干组,之前的操作需要保证每一组中的序列都是有序的.操作的顺序.初始的选择以及多次同一个操作对结果没影响.…