上一页 1 ··· 28 29 30 31 32 33 34 35 36 ··· 40 下一页

2013年4月18日

线段树 hdu 1166 敌兵布阵 单点更新区间求和

摘要: 敌兵布阵Time Limit: 2000/1000 MS (Java/Others)Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 25659Accepted Submission(s): 11092Problem DescriptionC国的死对头A国这段时间正在进行军事演习,所以C国间谍头子Derek和他手下Tidy又开始忙乎了。A国在海岸线沿直线布置了N个工兵营地,Derek和Tidy的任务就是要监视这些工兵营地的活动情况。由于采取了某种先进的监测手段,所以每个工兵营地的人数C国都掌握的一清二楚,每个工兵营地的人 阅读全文

posted @ 2013-04-18 16:39 电子幼体 阅读(132) 评论(0) 推荐(0) 编辑

2013年4月17日

hdu 3062 Party 2-SAT入门

摘要: PartyTime Limit: 2000/1000 MS (Java/Others)Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 2822Accepted Submission(s): 878Problem Description有n对夫妻被邀请参加一个聚会,因为场地的问题,每对夫妻中只有1人可以列席。在2n 个人中,某些人之间有着很大的矛盾(当然夫妻之间是没有矛盾的),有矛盾的2个人是不会同时出现在聚会上的。有没有可能会有n 个人同时列席?Inputn: 表示有n对夫妻被邀请 (n<= 1000)m: 表示 阅读全文

posted @ 2013-04-17 21:12 电子幼体 阅读(133) 评论(0) 推荐(0) 编辑

2-SAT模板

摘要: #include <iostream> #include <cstdio> #include <cstring> using namespace std; const int maxn=4444; const int maxm=1111111; struct EDGE{ int to; int w; int next; }edges[maxm]; int head[maxn]; int edge,node; int lowlink[maxn],pre[maxn],sccno[maxn],stk[maxn],top,dfs_clock,scc_cnt; voi 阅读全文

posted @ 2013-04-17 21:11 电子幼体 阅读(116) 评论(0) 推荐(0) 编辑

SCC的Kosaraju算法模板

摘要: //-----Kosaraju vector<int>G[maxn],G2[maxn]; vector<int>S; int vis[maxn],sccno[maxn],scc_cnt; void dfs1(int u) { if (vis[u]) return; vis[u]=1; for (int i=0;i<G[u].size();i++) dfs1(G[u][i]); S.push_back(u); } void dfs2(int u) { if (sccno[u]) return; sccno[u]=scc_cnt; fo... 阅读全文

posted @ 2013-04-17 19:53 电子幼体 阅读(173) 评论(0) 推荐(0) 编辑

hdu 2767 Proving Equivalences 等价性证明 强连通分量

摘要: Proving EquivalencesTime Limit: 4000/2000 MS (Java/Others)Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1641Accepted Submission(s): 619Problem DescriptionConsider the following exercise, found in a generic linear algebra textbook.Let A be an n × n matrix. Prove that the followin 阅读全文

posted @ 2013-04-17 15:07 电子幼体 阅读(175) 评论(0) 推荐(0) 编辑

SCC的Tarjan算法模板

摘要: #include <iostream> #include <vector> #include <stack> #include <cstring> #include <cstdio> using namespace std; const int maxn=41111; //-----Tarjan vector<int> G[maxn]; int pre[maxn],lowlink[maxn],sccno[maxn],dfs_clock,scc_cnt; stack<int> S; void dfs(int u) 阅读全文

posted @ 2013-04-17 14:58 电子幼体 阅读(600) 评论(0) 推荐(0) 编辑

2013年4月16日

Trie 模板

摘要: //用类,或者结构体定义都行 class trie { public: trie* next[26]; int num; int value; trie() { for(int i=0;i<26;i++) next[i]=0; value=0;//记录是不是一个单词 num=0;//记录单词出现的次数 } }root; //插入: void insert(trie* p,char* s) { p=&root; int k=0; while(s[k]!='\0') ... 阅读全文

posted @ 2013-04-16 20:49 电子幼体 阅读(140) 评论(0) 推荐(0) 编辑

POJ 2449 Remmarguts' Date k短路

摘要: Remmarguts' DateTime Limit:4000MSMemory Limit:65536KTotal Submissions:17094Accepted:4694Description"Good man never makes girls wait or breaks an appointment!" said the mandarin duck father. Softly touching his little ducks' head, he told them a story."Prince Remmarguts lives i 阅读全文

posted @ 2013-04-16 18:23 电子幼体 阅读(153) 评论(0) 推荐(0) 编辑

二分查找法的实现和应用汇总

摘要: 在学习算法的过程中,我们除了要了解某个算法的基本原理、实现方式,更重要的一个环节是利用big-O理论来分析算法的复杂度。在时间复杂度和空间复杂度之间,我们又会更注重时间复杂度。时间复杂度按优劣排差不多集中在:O(1), O(log n), O(n), O(n log n), O(n2), O(nk), O(2n)到目前位置,似乎我学到的算法中,时间复杂度是O(log n),好像就数二分查找法,其他的诸如排序算法都是 O(n log n)或者O(n2)。但是也正是因为有二分的 O(log n), 才让很多 O(n2)缩减到只要O(n log n)。关于二分查找法二分查找法主要是解决在“一堆数中找 阅读全文

posted @ 2013-04-16 15:43 电子幼体 阅读(157) 评论(0) 推荐(0) 编辑

省赛练习2 Doctor NiGONiGO’s multi-core CPU 最大费用最大流

摘要: Doctor NiGONiGO’s multi-core CPUTime Limit 2000msMemory Limit 65536KdescriptionDoctor NiGONiGO has developed a new kind of multi-core CPU, it works as follow. There are q (1 < q ≤ 50) identical cores in the CPU, and there are p (0 < p ≤ 200) jobs need to be done. Each job should run in some co 阅读全文

posted @ 2013-04-16 15:26 电子幼体 阅读(195) 评论(0) 推荐(0) 编辑

上一页 1 ··· 28 29 30 31 32 33 34 35 36 ··· 40 下一页

导航