上一页 1 ··· 9 10 11 12 13 14 15 16 17 ··· 42 下一页
摘要: 题意:在一个序列中找出最长的某个序列。找出的序列满足题中的条件。关键:对于 第 i 个位置上的数,要知道与之相隔至少d的位置上的数的大小。可以利用线段树进行统计,查询。更新的时候利用dp的思想。 1 /* 2 统计某一段内有多少比aim小的数据 3 在更新的时候利用了dp的思想。 4 */ 5 #include 6 #include 7 #include 8 #include 9 using namespace std;10 const int maxn = 100005;11 struct node{12 int sum,l,r;13 }anode[ maxn1 )64 ... 阅读全文
posted @ 2013-07-11 16:20 xxx0624 阅读(577) 评论(0) 推荐(0) 编辑
摘要: 一种比较挫的写法 1 /* 2 模拟 3 */ 4 #include 5 #include 6 #include 7 #include 8 #include 9 #include10 #include11 #include12 #include13 using namespace std;14 const int maxn = 105;15 16 int cmp( int a,int b ){17 return a>b;18 }19 20 int main(){21 int ca;22 scanf("%d",&ca);23 while( ca-- ){24 . 阅读全文
posted @ 2013-07-09 15:38 xxx0624 阅读(151) 评论(0) 推荐(0) 编辑
摘要: 模拟! 1 /* 2 计算过了D天后的日期 3 之前D天的日期 4 */ 5 #include 6 int judge_year( int year ){ 7 if( (year%4==0&&year%100!=0)||(year%400==0) ) 8 return true; 9 else 10 return false; 11 } 12 int judge_month( int mon ){ 13 if( mon==1||mon==3||mon==5||mon==7||mon==8||mon==10||mon==1... 阅读全文
posted @ 2013-07-09 12:10 xxx0624 阅读(299) 评论(0) 推荐(0) 编辑
摘要: 1 #include 2 int fast_pow( int a,int b,int mod ){ 3 int res = 1; 4 while( b>=1 ){ 5 if( b%2==1 ){ 6 res = res*a%mod; 7 } 8 a = a*a%mod; 9 b/=2;10 }11 return res;12 }13 int main(){14 int n;15 while( ~scanf("%d",&n) ){16 if( ... 阅读全文
posted @ 2013-07-07 23:17 xxx0624 阅读(220) 评论(0) 推荐(0) 编辑
摘要: 题意:找到一个这样的图,在这个图中,最多有一个环。使得所有的边的和最大。贪心+并查集首先把边排序,然后开始分类讨论。对于边ab(含有两个端点ab)如果a,b是属于两个不同的集合 a b 是两个环中的点,则放弃ab a b 有一个是环,则把环当做另一个的祖先,之后在回溯祖先的时候,能找到该点是在某个环中。。。。。 1 /* 2 找到一个图,使得每一个连通分量最多有一个环 3 */ 4 #include 5 #include 6 #include 7 #include 8 using namespace std; 9 const int maxn = 10005;10 const int ... 阅读全文
posted @ 2013-07-07 16:46 xxx0624 阅读(424) 评论(0) 推荐(0) 编辑
摘要: dp[ i ]表示该状态下得所需花费。 1 /* 2 状态压缩dp 3 dp[i] = min( dp[ i-j ]+cost[ j ] ); 4 由i-j的状态转到i的状态 5 */ 6 #include 7 #include 8 #include 9 #include10 #include11 using namespace std;12 const int maxn = 20;13 const double inf = 99999999.0;14 const int maxm = (11&&cntinf ) continue;50 for( int j=0;jdi... 阅读全文
posted @ 2013-07-07 10:29 xxx0624 阅读(313) 评论(0) 推荐(0) 编辑
摘要: 可用tarjan来做。。。 1 /* 2 lca+tarjan 3 */ 4 #include<stdio.h> 5 #include<string.h> 6 #include<stdlib.h> 7 #include<algorithm> 8 #include<iostream> 9 #include<queue> 10 #include<map> 11 #include<math.h> 12 using namespace std; 13 typedef long long ll; 14 //t 阅读全文
posted @ 2013-05-26 14:55 xxx0624 阅读(708) 评论(0) 推荐(0) 编辑
摘要: 1. 概述RMQ(Range Minimum/Maximum Query),即区间最值查询,是指这样一个问题:对于长度为n的数列A,回答若干询问RMQ(A,i,j)(i,j<=n),返回数列A中下标在 i,j之间的最小/大值。这两个问题是在实际应用中经常遇到的问题,下面介绍一下解决这两种问题的比较高效的算法。当然,该问题也可以用线段树(也叫区间树)解决,算法复杂度为:O(N)~O(logN),这里我们暂不介绍。 2.RMQ算法对于该问题,最容易想到的解决方案是遍历,复杂度是O(n)。但当数据量非常大且查询很频繁时,该算法无法在有效的时间内查询出正解。本节介绍了一种比较高效的在线算法(ST 阅读全文
posted @ 2013-05-25 20:01 xxx0624 阅读(144) 评论(0) 推荐(0) 编辑
摘要: wa的代码。。纯dfs 1 /* 2 LCA 3 */ 4 #include<stdio.h> 5 #include<string.h> 6 #include<stdlib.h> 7 #include<algorithm> 8 #include<iostream> 9 #include<queue>10 #include<map>11 #include<math.h>12 #pragma comment(linker, "/STACK:16777216")13 using nam 阅读全文
posted @ 2013-05-22 21:57 xxx0624 阅读(213) 评论(0) 推荐(0) 编辑
摘要: 简单LCA。。。。但是输入的时候很恶心。。。。看discuss,改了scanf才过了。。。 1 /* 2 LCA 3 */ 4 #include<stdio.h> 5 #include<string.h> 6 #include<stdlib.h> 7 #include<algorithm> 8 #include<iostream> 9 #include<queue>10 #include<map>11 #include<math.h>12 using namespace std;13 typedef 阅读全文
posted @ 2013-05-22 19:48 xxx0624 阅读(173) 评论(0) 推荐(0) 编辑
上一页 1 ··· 9 10 11 12 13 14 15 16 17 ··· 42 下一页