上一页 1 ··· 4 5 6 7 8 9 10 11 12 ··· 21 下一页
摘要: http://poj.org/problem?id=1151题意:给出矩形的左上角坐标和右下角坐标(坐标的y轴是向下的),求出矩形面积的并。。今天好困啊。。迷迷糊糊的听会神给讲了讲,敲完之后调试了好久。。原来存错数组了。。看来意识模糊的时候不适宜敲题。 1 #include 2 #include 3 #include 4 using namespace std; 5 const int N=550; 6 7 struct node 8 { 9 double x1,y1,x2,y2;10 } p[N];11 double X[N],Y[N];12 bool vis[N][N];1... 阅读全文
posted @ 2014-02-21 21:00 N_ll 阅读(285) 评论(0) 推荐(0)
摘要: http://poj.org/problem?id=2983题意:给出M条信息,判断这些信息的正确性。(1)V A B :表示A,B之间的距离>=1; (2)P A B X :表示A B之间的距离为x。思路:dis[i]表示i到原点的距离,由(1)知 dis[A]A之间有一条边,权值为-1;由(2)知: dis[A]B的权值为-x,B->A的权值为x。增加一个超级源点,与所有的点相连且权值为0.建图,spfa判断是否有负环(即判断进站次数,若大于点数则存在负环)。若存在负环则信息为假,否则为真。 1 #include 2 #include 3 #include 4 using na 阅读全文
posted @ 2014-02-20 21:28 N_ll 阅读(331) 评论(0) 推荐(0)
摘要: http://poj.org/problem?id=2406题意:计算一个串中重复因子出现的最多次数,即最多的循环节数。 1 #include 2 #include 3 const int N=1000010; 4 char str[N]; 5 int next[N]; 6 7 int get_next(char *s) 8 { 9 int j = 0,k = -1;10 int len=strlen(s);11 next[0]=-1;12 while(j<len)13 {14 if(k==-1||s[k]==s[j])15 ... 阅读全文
posted @ 2014-02-20 19:39 N_ll 阅读(188) 评论(0) 推荐(0)
摘要: http://poj.org/problem?id=3368题意:给出一个非降序排列的整数数组,对于询问(i,j),输出区间[i,j]中出现最多的值的次数。思路:经典的RMQ,不过我用线段树做的。首先要离散化,因为是非降序的,所以相同的数是连续的,可以将相同的数分在同一个块中,将块中的信息存储起来,然后将其看成一个点,就可以用线段树进行查询了。 1 #include 2 #include 3 #include 4 using namespace std; 5 const int N=1000010; 6 struct node 7 { 8 int l,r; 9 int M... 阅读全文
posted @ 2014-02-20 16:45 N_ll 阅读(462) 评论(0) 推荐(0)
摘要: http://poj.org/problem?id=3264题意:n个数,q个询问,输出[l,r]中最大值与最小值的差。 1 #include 2 #include 3 #include 4 using namespace std; 5 const int N=1000010; 6 struct node 7 { 8 int l,r; 9 int Max,Min;10 } Tree[N*4];11 int h[N],max1=0,min1=N;12 void build(int l,int r,int rt)13 {14 Tree[rt].l = l;15 ... 阅读全文
posted @ 2014-02-20 13:08 N_ll 阅读(213) 评论(0) 推荐(0)
摘要: http://poj.org/problem?id=2750题意:在一个圈中取若干个相邻的数,求他们的最大序列和。不能够同时取所有的数。看了一篇解题报告写的很详细。。http://blog.csdn.net/non_cease/article/details/7437690 1 #include 2 #include 3 #include 4 #include 5 const int N=100010; 6 using namespace std; 7 struct node 8 { 9 int l,r,sum,minsum,maxsum;10 int lmax,rma... 阅读全文
posted @ 2014-02-20 10:12 N_ll 阅读(307) 评论(0) 推荐(0)
摘要: http://poj.org/problem?id=2777题意:有一艘长为L的船,初始颜色为1,将船分为L段,用T种颜色去染。有O种操作,C A B C:表示将区间[A,B]段染成C颜色。 P A B:表示询问[A,B]段中有多少不同的颜色。思路:线段树的区间修改。 1 #include 2 #include 3 #include 4 #define lson l,mid,rt>1; 21 build(lson); 22 build(rson); 23 } 24 void pushdow(int rt)//标记传递 25 { 26 if (Tree[rt... 阅读全文
posted @ 2014-02-19 15:28 N_ll 阅读(447) 评论(0) 推荐(0)
摘要: http://poj.org/problem?id=2828题意:有n个人排队买票,每个人的位置为pos(0~n-1),价值是val,如果位置相同,来的晚的人可以插入他选的位置。最后输出队列中的val。 1 #include 2 #include 3 const int N=200010; 4 int Tree[N*4],seq[N]; 5 int pos[N],val[N]; 6 7 void build(int l,int r,int rt) 8 { 9 Tree[rt]=r-l+1;//初始每个区间的空位数10 if(l==r)11 return;1... 阅读全文
posted @ 2014-02-18 15:54 N_ll 阅读(193) 评论(0) 推荐(0)
摘要: http://poj.org/problem?id=3308题意:一个m*n的网格,有L位火星空降兵降落在网格中,地球卫士为了能同时消灭他们,在网格的行或列安装了一个枪支,每行或每列的枪支都能消灭这一整行或整列的空降兵,给出每一行和每一列安装枪支的花费,总的花费等于所有安装枪支的行和列的花费的乘积。求出最小的总的花费。思路:(1)最小割:对于图中的两个点(一般为源点和汇点)来说,如果把图中的一些边去掉,如果它们之间无法连通的话,则这些边组成的集合就叫为割了。如果这些边有权值,最小割就是指权值之和最小的一个割。(2)对任意一个只有一个源点和一个汇点的图来说,从源点到汇点的最大流等于最小割,可以用 阅读全文
posted @ 2014-02-18 08:55 N_ll 阅读(284) 评论(0) 推荐(0)
摘要: http://poj.org/problem?id=2942题意:n个武士,某些武士之间相互仇视,如果在一起容易发生争斗事件。所以他们只有满足一定的条件才能参加圆桌会议:(1)相互仇视的两个武士不能相邻 (2)同一个圆桌边上的武士数量必须是奇数。输出需要剔除的武士人数。 / \思路:根据图中的关系建立该图的补图,(Tarjan算法)求出图中的双连通分量,判断每个双连通分量中是否存在奇圈,若存在奇圈则该连通分量中的武士都符合条件,否则都不符合 |.| 判断奇圈的方法:由于二分图中不含奇圈,可判断连通分量是否为二分图,若是,则不含奇圈,否则存在奇圈。。 |.| |:| __ ,_|:... 阅读全文
posted @ 2014-02-17 15:09 N_ll 阅读(270) 评论(0) 推荐(0)
上一页 1 ··· 4 5 6 7 8 9 10 11 12 ··· 21 下一页