上一页 1 ··· 8 9 10 11 12 13 14 15 16 ··· 18 下一页
摘要: 堆。 一道模拟,不过不同的人模拟出来的效果差距很大,比方说我抄的这个就太劲了。。 #include #include #include #include using namespace std; struct data { int n,s,t,p; data() {} data(int n,int s,int t,int p):n(n),s(s),t(t),p(p... 阅读全文
posted @ 2016-05-27 23:12 invoid 阅读(119) 评论(0) 推荐(0) 编辑
摘要: 题目大意: 在n个点中,选出k对相邻的互不相同的点,使k段距离的总和最小。 贪心,双向链表。 首先,点之间的距离是动态的,所以要用堆来维护。 每次都选择最近的点。但因为其他情况,可能最终不会选择这对点连在一起 所以把俩个点旁边的路径的和减去俩个点之间距离再加进去,表示连旁边的俩条边,不连现在的边。 要维护许多信息。 #include #include #include us... 阅读全文
posted @ 2016-05-27 20:39 invoid 阅读(554) 评论(0) 推荐(0) 编辑
摘要: 二分图匹配。 补充,感觉之前说的不够详细,如果有完美匹配的话,每行都有一个对应的列,那么换来换去以后,对角线就全黑了。。。 #include #include #include using namespace std; const int maxn = 400 + 10; bool vis[maxn]; int p[maxn],map[maxn][maxn]; int n,T; ... 阅读全文
posted @ 2016-05-25 19:30 invoid 阅读(150) 评论(0) 推荐(0) 编辑
摘要: 斜率优化。 大水题。。。 #include #include #include using namespace std; const int maxn = 1000000 + 10; int q[maxn],l,r; long long f[maxn],s[maxn],a,b,c,x; int n,m; inline long long sqr(long long x) { ... 阅读全文
posted @ 2016-05-25 18:01 invoid 阅读(129) 评论(0) 推荐(0) 编辑
摘要: 不知道什么算法。 首先求一颗植物(i,j)与能量采集器的连线上有几颗植物。 答案是(gcd(i,j)-1),设i’= i/gcd(i,j),j’=j/gcd(i,j). 则这几颗植物是(i’k,j’k) 1 #include #include using namespace std; const int maxn = 100000 + 10; long long ans[maxn],... 阅读全文
posted @ 2016-05-25 17:11 invoid 阅读(111) 评论(0) 推荐(0) 编辑
摘要: 矩阵乘法. 10^k,0,0 (f[i+1],i+1,1) = (f[i],i,1) ( 1, 1,0 ) 1. 1,0) k为(i+1)的位数。这点很重要,所以每回都是算到999…9,然后k就会+1。所以题目中的l和... 阅读全文
posted @ 2016-05-25 10:20 invoid 阅读(127) 评论(0) 推荐(0) 编辑
摘要: KMP。 一直没有一个裸kmp,根本看不懂kmp。。。//蒟蒻本性。 kmp的部分匹配值next[j],在这个实现中的意思是,如果b[j+1]和a[i]失配,j=next[j]。 就是不断返回直到b[j+1]==a[i]。 计算的话,就用自己匹配自己吧。 阅读全文
posted @ 2016-05-24 16:38 invoid 阅读(240) 评论(0) 推荐(0) 编辑
摘要: 矩阵乘法的通俗的我自己用的理解方式 C=AB. 则Cij=∑aikbkj (k属于那个范围),所以首先矩阵相乘的必须是A矩阵的列数等于b矩阵的行数。 第二就是C的意义了,cij表示A的第i行与B的第j列每个数对应相乘,因为上面的条件,所以A的第i行的数的数目恰好等于B的第j列数的数目。 c也正好是i行j列。 下面是我看懂矩阵乘法的网址,讲的确实不错。 http://www.ruanyif... 阅读全文
posted @ 2016-05-24 16:15 invoid 阅读(190) 评论(0) 推荐(0) 编辑
摘要: 二分。 #include #include #include using namespace std; const int maxn = 50000 + 10; int n,k,l,r,mid,ans,d; int a[maxn]; bool check(int dist) { dist=2*dist; int d=0,sum=1; for(int i=2;id... 阅读全文
posted @ 2016-05-20 21:32 invoid 阅读(146) 评论(0) 推荐(0) 编辑
摘要: 前缀和. 设f[i]为前缀和%7=i的第一个点。那么答案就是max(i-f[s[i]%7])了。 #include #include #include using namespace std; const int maxn = 50000 + 10; int a[maxn],s[maxn]; int f[10],n,ans; int main() { for(int i... 阅读全文
posted @ 2016-05-20 21:31 invoid 阅读(313) 评论(0) 推荐(0) 编辑
上一页 1 ··· 8 9 10 11 12 13 14 15 16 ··· 18 下一页