10 2013 档案

摘要:比较巧妙的一道题目,拿到题目就想用暴力直接搜索,仔细分析了下发现复杂度达到了2^n*n! ,明显不行,于是只好往背包上想。 于是又想二分找次数判断可行的方法,但是发现复杂度10^8还是很悬。。。然后学习了这种背包状压的好思路, 巧妙的转化成了背包的模型。 一道经典的题目!RelocationTime Limit:1000MSMemory Limit:65536KTotal Submissions:1664Accepted:678DescriptionEmma and Eric are moving to their new house they bought after returning f 阅读全文
posted @ 2013-10-31 13:54 chenhuan001 阅读(328) 评论(0) 推荐(0) 编辑
摘要:http://wenku.baidu.com/view/728cd5126edb6f1aff001fbb.html关于悬线法,这里面有详解。我当时只想到了记录最大长度,却没有想到如果连最左边和最右边的位置都记录的话这题就可以解决了。 学习了一种新算法很开心。Cut the cakeTime Limit: 6000/3000 MS (Java/Others)Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 881Accepted Submission(s): 328Problem DescriptionMark bough 阅读全文
posted @ 2013-10-22 22:21 chenhuan001 阅读(1306) 评论(0) 推荐(0) 编辑
摘要:比赛的时候没有想到二分图,一直在想dp和贪心。 原因是因为看到数据是100000所以直接就没有往二分图匹配上想。现在想想。 因为二分图两边的太不对称了,60 和100000 , 如果用匈牙利算法考虑的话,左边的点应该可以很快的找到一个与之匹配的点。 如果边不多的话那么找起来也是很快的。还是太弱。I'm Telling the TruthTime Limit: 2000/1000 MS (Java/Others)Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1129Accepted Submission(s): 阅读全文
posted @ 2013-10-20 18:38 chenhuan001 阅读(469) 评论(0) 推荐(0) 编辑
摘要:总是不能正确的将一个大问题变成子问题,而且又找不到状态转移方程。 直接导致这题想了5个小时最后还是无果。。。谨记!Number StringTime Limit: 10000/5000 MS (Java/Others)Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1136Accepted Submission(s): 503Problem DescriptionThe signature of a permutation is a string that is computed as follows: for eac 阅读全文
posted @ 2013-10-19 12:47 chenhuan001 阅读(290) 评论(0) 推荐(0) 编辑
摘要:比赛的时候不知道怎么写。。。 太弱了。看了别人的代码,觉得这个是个经典的知识点吧。 gcd的巧妙运用自己想的时候苦苦思考怎么用dp求解。 无奈字符串太长而想不出好的算法。其实在把a和b字符串都分成以gcd(a,b)长度为单位的字符串时。 设为la=a/gcd(a,b) ,lb=b/gcd(a,b) . 明显可以知道的是gcd(la,lb)==1, 所以la与lb长度的字符串要分别拼接lb和la次才能拼成两个相等的串. 这样就有了解法. for(int i=0;i<lena;i++) dpa[i%k][a[i]-'a']++; // 统计在a串 在gcd(a,b)长度某一位 阅读全文
posted @ 2013-10-16 15:37 chenhuan001 阅读(484) 评论(0) 推荐(0) 编辑
摘要:求N个数阶乘末尾除0后的数值。主要的难点在于要把这个N个数所含的2和5的队数去掉。网上方法很多很好。 不多说Last non-zero Digit in N!Time Limit: 2000/1000 MS (Java/Others)Memory Limit: 65536/32768 K (Java... 阅读全文
posted @ 2013-10-09 13:28 chenhuan001 阅读(654) 评论(0) 推荐(0) 编辑
摘要:dp还是比较好想的,但是时间还是比较坑的。 要预处理还加些优化才行 。#include #include #include #include #include #include #include #include #include using namespace std;#define INF 0x3fffffff#define MOD 1000000007int n,m,k;int dp[101][1010][35];int save[1010][1010];int g[35];int cnt=0;int mark[1100];//bool mark1[1100][1100];int gcd 阅读全文
posted @ 2013-10-07 22:02 chenhuan001 阅读(211) 评论(0) 推荐(0) 编辑
摘要:这种思想很经典。 从最小的边选择,那么可以知道的是,在除去这条边的另外两个联通块,选其中一块中的点做为源点到另一块所得到的费用和。 如果你已经知道了这两个联通块内部选一个点时的最大费用和。那么这题就可以直接得到答案了,然后用递归思想独立的求这两块联通块。但是这样不好实现。 如果再反着想, 把边从大到小放入图中然后记录每个联通块的最大值。 然后就是合并的时候选择的问题了 。经典的思想,要好好记下 。#include #include #include #include #include #include #include #include #include using namespace std 阅读全文
posted @ 2013-10-07 08:57 chenhuan001 阅读(408) 评论(0) 推荐(0) 编辑
摘要:注意题目的一个关键条件(a-1)2 2 #include 3 #include 4 #include 5 #include 6 #include 7 #include 8 #include 9 #include 10 using namespace std;11 #define INF 0x3fffffff12 13 typedef __int64 LL;14 15 LL a,b,n,m;16 LL g[2][2];17 LL MOD;18 19 void cal(LL s[2][2],LL t[2][2])20 {21 LL tmp[2][2];22 memse... 阅读全文
posted @ 2013-10-03 22:00 chenhuan001 阅读(339) 评论(0) 推荐(0) 编辑
摘要:int stk[N],vis[N],low[N],link[N],mark[N];int top,index,id,du[N];//记录入度数int pre[N],cnt,g[N];// g 用来记录topsort后的结果int g1[N]; //用来记录缩点后的每一个点所含的点void dfs(int s){ mark[s]=1; vis[s]=index++; low[s]=vis[s]; stk[top++]=s; for(int p=pre[s];p!=-1;p=edge[p].next) { int v=edge[p].to; ... 阅读全文
posted @ 2013-10-03 17:14 chenhuan001 阅读(355) 评论(0) 推荐(0) 编辑
摘要:数位dp每次都给我一种繁琐的感觉。。A -Palindromic NumbersTime Limit:2000MSMemory Limit:32768KB64bit IO Format:%lld & %lluSubmitStatusDescriptionA palindromic number or numeral palindrome is a 'symmetrical' number like 16461 that remains the same when its digits are reversed. In this problem you will be g 阅读全文
posted @ 2013-10-03 12:10 chenhuan001 阅读(330) 评论(1) 推荐(0) 编辑
摘要://还需加PI 和 mabs 函数double chg(double x,double y){ double tmps; if(mabs(x-0)0) tmps=90.0; else tmps=270.0; } else { tmps=y/x; //将这个点的斜率求出来 if(mabs(y-0)0) tmps=0.0; else tmps=180.0; } else { tmps=atan(tmps);//求出角度 ... 阅读全文
posted @ 2013-10-02 21:56 chenhuan001 阅读(197) 评论(0) 推荐(0) 编辑
摘要:枚举所有可能的半径,然后将所有满足这个半径的点按角度(与x轴正半轴的夹角)排序。 然后一遍扫描求出在这个半径下选k个点所需的最小面积 。思路还是比较简单,实现略有些繁琐。要先将点的坐标转换为角度。 如果用斜率的方法的话有些繁琐。Fire-Control SystemTime Limit: 12000/5000 MS (Java/Others)Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 2047Accepted Submission(s): 350Problem DescriptionA new mighty wea 阅读全文
posted @ 2013-10-02 21:49 chenhuan001 阅读(373) 评论(0) 推荐(0) 编辑
摘要:基础的2-SAT求任意方案的题目。Priest John's Busiest DayTime Limit: 2000MSMemory Limit: 65536KTotal Submissions: 7309Accepted: 2492Special JudgeDescriptionJohn is the only priest in his town. September 1st is the John's busiest day in a year because there is an old legend in the town that the couple who g 阅读全文
posted @ 2013-10-01 22:37 chenhuan001 阅读(304) 评论(0) 推荐(0) 编辑
摘要:2-SAT 求出可能的解,但是这个解要是字典序最小的,所以只能采用2-SAT基本思想来解。从小到大开始,对一个可能的点染色,染为1,然后dfs其所有能到达的点,如果其中出现一个已经标号为-1的话,那么就说明这个点不能选。 然后把之前标好的号清除掉。 如果没有出现的话,那么就保持染色。 如果出现同一集合的两个点都不能染色的话就说明无解。 否则输出所有染为1的点。Peaceful CommissionTime Limit: 10000/5000 MS (Java/Others)Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 阅读全文
posted @ 2013-10-01 15:05 chenhuan001 阅读(263) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示