Shirlies
宁静专注认真的程序媛~
上一页 1 ··· 3 4 5 6 7 8 9 10 11 ··· 21 下一页
摘要: 一道线段树的题目,由于之前没怎么做过线段树的题目,这道题我觉得还是有点小难的首先将x坐标排序,然后找相邻的x坐标之间的最大y值和最小y值,这些矩形是要覆盖x,x+1坐标的,然后将yMax,yMin分散到线段树上,并用一个值标记哪些节点被分布了,最后查找一遍就可以了。代码如下: 1 #include <iostream> 2 #include <algorithm> 3 #include <cstring> 4 using namespace std; 5 6 int X_axle[20000]; 7 8 struct node 9 { 10 int xLow 阅读全文
posted @ 2012-11-29 14:24 Shirlies 阅读(332) 评论(0) 推荐(0) 编辑
摘要: http://acm.hdu.edu.cn/webcontest/contest_show.php?cid=3404DP专题训练一道整数划分的题目将M个蛋糕放在N个盘子里面当M>N时,可以先在每个盘子里面放一个蛋糕,剩下M-N的蛋糕放在N个盘子里面,也可以腾出一个盘子来,用剩下的盘子放M的蛋糕,则f(N,M)=f(N,M-N)+f(N-1,M);当M=N时,可以每个盘子放一个蛋糕,也可以空闲一个盘子,则f(N,M) = f(N-1,M) + 1;当M< N 时,肯定会空盘子,则f(N,M) = f(N-1,M);代码如下: 1 #include <iostream> 2 阅读全文
posted @ 2012-10-17 22:48 Shirlies 阅读(468) 评论(0) 推荐(0) 编辑
摘要: 直接暴力,虽然效率很差。。。。。。View Code 1 #include <iostream> 2 #include <queue> 3 using namespace std; 4 5 struct node 6 { 7 char name[100]; 8 int para; 9 int prio;10 int id;11 friend bool operator < (const node& a,const node& b)12 {13 if(a.prio == b.prio)14 return ... 阅读全文
posted @ 2012-09-22 21:03 Shirlies 阅读(191) 评论(0) 推荐(0) 编辑
摘要: 直接模拟。。。View Code 1 #include <iostream> 2 #include <cstring> 3 #include <queue> 4 using namespace std; 5 6 typedef pair<int,int> pii; 7 8 struct node 9 {10 int id,kb;11 node(){}12 node(int a,int b)13 {14 id = b;15 kb = a;16 }17 friend bool operator <(const n... 阅读全文
posted @ 2012-09-21 23:08 Shirlies 阅读(249) 评论(0) 推荐(0) 编辑
摘要: 简单题,直接模拟,但是还是要仔细点。。。View Code 1 #include <iostream> 2 #include <stack> 3 #include <iomanip> 4 #include <ios> 5 using namespace std; 6 7 int main() 8 { 9 double a;10 while(cin >> a)11 {12 stack<double> Snum;13 stack<char> Sop;14 15 Snum.push(a);16 char ch... 阅读全文
posted @ 2012-09-21 22:32 Shirlies 阅读(294) 评论(0) 推荐(0) 编辑
摘要: 狂晕,是我做题太少了吧?我竟然直接按输入输出的模式做题,即输出“Output for Sample Input 1”,呜呜,WA了几次就是因为这个。。。。。。。。。。。。。。。。。。。。。。。。。。。View Code 1 #include <iostream> 2 #include <vector> 3 #include <cstring> 4 #include <algorithm> 5 using namespace std; 6 7 const int maxN = 1000+10; 8 int low[maxN]; 9 int DFN[ 阅读全文
posted @ 2012-09-14 20:51 Shirlies 阅读(216) 评论(0) 推荐(0) 编辑
摘要: 将图变成双连通图,缩点,考虑该点与其他点相连的个数,如果只有一条边与其他点相连,则需要加一条边,因为这里面的点只能通过一条边到其他点,加一条边让它们能够通过另一条边到达其他点。View Code 1 #include <iostream> 2 #include <cstring> 3 #include <vector> 4 using namespace std; 5 6 const int maxN = 5000+10; 7 int low[maxN]; 8 int DFN[maxN]; 9 int degree[maxN];10 int cnt;11 1 阅读全文
posted @ 2012-09-13 21:19 Shirlies 阅读(158) 评论(0) 推荐(0) 编辑
摘要: 先用Tarjan求出强连通分量,其他算法也可以的,再缩点,然后从入度为0的点开始暴搜,如果深度达到强连通分量的个数即可行。这一题一定要注意一点:我用cin的时候TLE,该scanf就好了。。。View Code 1 #include <cstdio> 2 #include <cstring> 3 #include <vector> 4 using namespace std; 5 6 const int maxN = 1000 + 10; 7 vector<int> edge[maxN]; 8 int low[maxN]; 9 int stack 阅读全文
posted @ 2012-09-09 21:05 Shirlies 阅读(162) 评论(0) 推荐(0) 编辑
摘要: 三种方法求极大强连通分支的算法,一题一种方法poj 2186 求牛被所有其它的牛崇拜的个数,在一个强连通分量里面的牛是互相崇拜的,所以如果这个强连通分支被其它牛崇拜那么这里面的牛都被其它牛崇拜.。。。这一题我用的Tarjan算法View Code 1 #include <iostream> 2 #include <cstring> 3 #include <vector> 4 using namespace std; 5 6 const int maxN = 10000+10; 7 int low[maxN]; 8 int stack[maxN],top; 9 阅读全文
posted @ 2012-09-08 22:14 Shirlies 阅读(250) 评论(0) 推荐(0) 编辑
摘要: Havel-Hakimi定理http://blog.sina.com.cn/s/blog_818d3d930100wdv1.htmlhttp://hi.baidu.com/krdefndrsbbekmd/item/a7c58810f40156f8dceecab7View Code 1 #include <iostream> 2 #include <cstring> 3 #include <algorithm> 4 using namespace std; 5 6 struct node 7 { 8 int u; 9 int dg;10 }p[15];11 i 阅读全文
posted @ 2012-09-05 09:43 Shirlies 阅读(223) 评论(0) 推荐(0) 编辑
上一页 1 ··· 3 4 5 6 7 8 9 10 11 ··· 21 下一页