07 2013 档案

【专题】图的连通性问题
摘要:有向图的强连通分量POJ 1236 - Network of Schools(基础)http://acm.pku.edu.cn/JudgeOnline/problem?id=1236题意:问添加多少边可成为完全连通图解法:缩点,看度数/** head-file **/ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include /** define-fo... 阅读全文

posted @ 2013-07-28 19:47 电子幼体 阅读(145) 评论(0) 推荐(0)

[置顶] 【专题】单调队列/斜率优化DP
摘要:一、单调队列志愿者选拔O(n)struct STU{ char name[7]; int rp; }; int que[2111111]; int idx[2111111]; int main() { int T,head,tail; char gs[111]; scanf("%d",&T); while (T--) { int cas,cnt; head=tail=0; cas=cnt=0; while (scanf("%s",gs)) { ... 阅读全文

posted @ 2013-07-25 11:04 电子幼体 阅读(131) 评论(0) 推荐(0)

【专题】单调队列/斜率优化DP
摘要:一、单调队列志愿者选拔O(n)struct STU{ char name[7]; int rp;};int que[2111111];int idx[2111111];int main(){ int T,head,tail; char gs[111]; scanf("%d",&T); while (T--) { int cas,cnt; head=tail=0; cas=cnt=0; while (scanf("%s",gs)) { if (strcmp(gs,... 阅读全文

posted @ 2013-07-25 11:04 电子幼体 阅读(189) 评论(0) 推荐(0)

MUTC8 E- One hundred layer 单调队列dp
摘要:One hundred layerTime Limit: 2000/1000 MS (Java/Others)Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 1257Accepted Submission(s): 467Problem DescriptionNow there is a game called the new man down 100th floor. The rules of this game is: 1.At first you are at the 1st floor. And the flo. 阅读全文

posted @ 2013-07-25 10:55 电子幼体 阅读(172) 评论(0) 推荐(0)

MUTC8 J-The More The Better
摘要:The More The BetterTime Limit: 4000/2000 MS (Java/Others)Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 2568Accepted Submission(s): 668Problem DescriptionGiven an sequence of numbers {X1, X2, ... , Xn}, where Xk= (A * k + B) % mod. Your task is to find the maximum sub sequence {Y1, Y2 阅读全文

posted @ 2013-07-25 10:53 电子幼体 阅读(197) 评论(0) 推荐(0)

RMQ 模板
摘要:一维模板const int maxn=50001; class CRMQ { private: int Max[20][maxn]; int Min[20][maxn]; int idx[maxn]; public: int val[maxn]; void initRMQ(int n) { idx[0]=-1; for (int i=1; i>1)]); Max[i][j]=max(Max[i-1][j],Max[i-1][j+(1>1)]); ... 阅读全文

posted @ 2013-07-24 16:22 电子幼体 阅读(136) 评论(0) 推荐(0)

poj 2449 k短路--模板
摘要:Remmarguts' DateTime Limit:4000MSMemory Limit:65536KTotal Submissions:17853Accepted:4879Description"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-07-24 15:08 电子幼体 阅读(126) 评论(0) 推荐(0)

MUTC2013 E-Deque-hdu 4604
摘要:DequeTime Limit: 4000/2000 MS (Java/Others)Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 786Accepted Submission(s): 253Problem DescriptionToday, the teacher gave Alice extra homework for the girl weren't attentive in his class. It's hard, and Alice is going to turn to you for 阅读全文

posted @ 2013-07-24 14:37 电子幼体 阅读(169) 评论(0) 推荐(0)

MUTC7 C - Dragon Ball 单调队列dp
摘要:Dragon BallTime Limit: 3000/1500 MS (Java/Others)Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 1680Accepted Submission(s): 614Problem DescriptionSean has got a Treasure map which shows when and where the dragon balls will appear. some dragon balls will appear in a line at the same ti 阅读全文

posted @ 2013-07-24 11:52 电子幼体 阅读(172) 评论(0) 推荐(0)

MUTC7 A-As long as Binbin loves Sangsang
摘要:As long as Binbin loves SangsangTime Limit: 2000/1000 MS (Java/Others)Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 2053Accepted Submission(s): 501Problem DescriptionBinbin misses Sangsang so much. He wants to meet with Sangsang as soon as possible.Now Binbin downloads a map from ELG 阅读全文

posted @ 2013-07-24 10:43 电子幼体 阅读(206) 评论(0) 推荐(0)

MUTC2013 J-I-number-hdu4608
摘要:I-numberTime Limit: 10000/5000 MS (Java/Others)Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 195Accepted Submission(s): 75Problem DescriptionThe I-number of x is defined to be an integer y, which satisfied the the conditions below:1.y>x;2.the sum of each digit of y(under base 10) 阅读全文

posted @ 2013-07-23 19:32 电子幼体 阅读(271) 评论(0) 推荐(0)

MUTC2013 H-Park Visit-hdu4607
摘要:Park VisitTime Limit: 6000/3000 MS (Java/Others)Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 85Accepted Submission(s): 34Problem DescriptionClaire and her little friend, ykwd, are travelling in Shevchenko's Park! The park is beautiful - but large, indeed. N feature spots in the 阅读全文

posted @ 2013-07-23 19:07 电子幼体 阅读(228) 评论(0) 推荐(0)

模板NeverGiveUpNeverSurrenderTerribleTerribleDamage-PowerOverwhelming
摘要:NGUNSTTD-POName: NeverGiveUpNeverSurrenderTerribleTerribleDamage-PowerOverwhelmingUsage: Put it before main functionTags: 头文件 循环 常用语句/** head-file **/ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include... 阅读全文

posted @ 2013-07-22 22:33 电子幼体 阅读(193) 评论(0) 推荐(0)

Topcoder SRM 585 DIV2 解题报告 //缺1000
摘要:------------LISNumberDivTwo最小的连续递增子序列的个数。。。----从前往后扫描一遍即可。。#include #include #include #include using namespace std; class LISNumberDivTwo{ private: public: int calculate(vector seq) { int ans=0; int n=seq.size(); for (int i=0;i0)f[0]=... 阅读全文

posted @ 2013-07-21 22:50 电子幼体 阅读(159) 评论(0) 推荐(0)

Codeforces Round #192 (Div. 2) 解题报告 //缺E
摘要:---------------A. CakeminatorrXc的蛋糕中有一些邪恶的草莓,如果某一行或某一列没有草莓我们可以吃掉这一排。问最多能吃多少蛋糕。----直接暴力寻找空行空列即可。#include #include using namespace std; const int maxn=21; char s[maxn][maxn]; bool v[maxn][maxn]; int r,c; int main() { memset(v,0,sizeof(v)); cin>>r>>c; for (int i=1;i>(s[i]+1); for ... 阅读全文

posted @ 2013-07-21 22:34 电子幼体 阅读(113) 评论(0) 推荐(0)

Codeforces Round #188 (Div. 2) 解题报告 //缺E
摘要:----------------------------A. Even Odds将1到n中的奇数排到前面偶数排到后面,问第k个数是多少。----嗯。。。math#include #include #include using namespace std; typedef long long LL; LL n,d,k,m; int main() { cin>>n>>k; m=(n+1)/2; if (k #include #include #include #include using namespace std; typedef long long... 阅读全文

posted @ 2013-07-16 11:35 电子幼体 阅读(134) 评论(0) 推荐(0)

Codeforces Round #189 (Div. 2) 解题报告
摘要:----------------A. Magic Numbers一个神奇的数字是由1、14、144连接而成的,判断一个数字是不是神奇数字。----①没有连续3个以上的4。②首位不能为4。数据范围太大,最好按字符读入。#include #include #include using namespace std; char c; int n,num; bool flag; int main() { flag=true; num=0; n=0; while (cin>>c) { if (n==0&&c!='1') { ... 阅读全文

posted @ 2013-07-13 20:17 电子幼体 阅读(200) 评论(0) 推荐(0)

Topcoder SRM 583 DIV2 解题报告
摘要:-----------------250SwappingDigits给一个数字串,要求交换两个数字的位置得到一个尽可能小的数字。(可以不交换)----从高位向低位枚举,对每一位,从低位向高位找一个比它小的数,若能找到则交换即答案。对首位不能为0进行特殊处理。#include #include #include using namespace std; class SwappingDigits{ private: public: string minNumber(string num) { int n=num.le... 阅读全文

posted @ 2013-07-13 17:45 电子幼体 阅读(251) 评论(0) 推荐(0)

Topcoder SRM 584 DIV2 解题报告
摘要:------------250TopFox给两个字符串,求有多少种不同的前缀和。----直接枚举前缀,压入set即可。#include #include #include #include #include #include #include using namespace std; class TopFox{ public: int possibleHandles(string a,string b) { int ans; setst; for (int i=0;i... 阅读全文

posted @ 2013-07-11 11:40 电子幼体 阅读(203) 评论(0) 推荐(0)

Codeforces Round #191 (Div. 2) 解题报告
摘要:------------A. Flipping Game有n个整数a1, a2, ..., an,每个整数只可能为0或1。选择一个区间[i, j](i #include #include #include using namespace std; const int INF=1e9; int a[111]={0}; int f[111]={0}; int n; int main() { int ans; int bas; while (cin>>n) { ans=-INF; bas=0; for (int... 阅读全文

posted @ 2013-07-08 18:20 电子幼体 阅读(183) 评论(0) 推荐(0)

详细解说 STL 排序(Sort)
摘要:详细解说 STL 排序(Sort)一切复杂的排序操作,都可以通过STL方便实现!0 前言: STL,为什么你必须掌握对于程序员来说,数据结构是必修的一门课。从查找到排序,从链表到二叉树,几乎所有的算法和原理都需要理解,理解不了也要死记硬背下来。幸运的是这些理论都已经比较成熟,算法也基本固定下来,不需要你再去花费心思去考虑其算法原理,也不用再去验证其准确性。不过,等你开始应用计算机语言来工作的时候,你会发现,面对不同的需求你需要一次又一次去用代码重复实现这些已经成熟的算法,而且会一次又一次陷入一些由于自己疏忽而产生的bug中。这时,你想找一种工具,已经帮你实现这些功能,你想怎么用就怎么用,同时不 阅读全文

posted @ 2013-07-02 18:46 电子幼体 阅读(175) 评论(0) 推荐(0)

Codeforces Round #190 (Div. 2) E. Ciel the Commander 题目与题解翻译
摘要:E. Ciel the Commandertime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard output现在Fox Ciel成为了Tree Land的指挥官。Tree Land,正如它的名字所说,有n个城市由n-1条无向道路连接,并且其中任意两个城市之间总是存在一条路径。Fox Ciel需要在每个城市分配一个官员。每个官员都有一个等级---一个’A’到’Z’之间的字母。所以会有26个不同的等级,’A’是最高的,’Z’是最低的。每个等级都有足够的官员。但是必 阅读全文

posted @ 2013-07-01 18:48 电子幼体 阅读(165) 评论(0) 推荐(0)

树的直径与树的中心
摘要:1. 树的直径概念:树中的最长路。求法:两次深搜或DP。1-两次深搜:任找一点A为源点,深搜遍历得到最远点B,这个最远点B必定在直径中(感性想想,以A点为源点找到的最长路后面一段必定属于树的直径的一部分);再以这个最远点B为源点深搜遍历求一个最长路,这个最长路即为树的直径。2-DP:显然最长路的两个端点必然是叶子或者根节点。设f(i)表示到i最远的叶子,g(i)表示到i次远的叶子,则有f(i)=max{f(j)}+1;g(i)=second{f(j)}+1;其中j必须是i的儿子,计算顺序是自底向上。最终答案为max{f(i)+g(i)}+12. 树的中心概念:树的直径的中点。求法:有多种,如D 阅读全文

posted @ 2013-07-01 16:06 电子幼体 阅读(467) 评论(0) 推荐(1)

导航