CodeForces 689 D Friends and Subsequences】的更多相关文章

Friends and Subsequences 题解: 如果左端点来说, 那么对于a[i]来说是向上的一条折线, b[i]来说是向下的一条折线, 那么如果这2个折线求交点个数的话, 我们可以二分去求第一个 a[i] == b[i] 的地方, 求最后一个a[i] == b[i]的地方. 代码: #include<bits/stdc++.h> using namespace std; #define Fopen freopen("_in.txt","r",…
codeforces 689 Mike and Shortcuts(最短路) 原题 任意两点的距离是序号差,那么相邻点之间建边即可,同时加上题目提供的边 跑一遍dijkstra可得1点到每个点的最短路,时间复杂度是O(mlogm) #include <cstdio> #include <iostream> #include <cstring> #include <queue> #include <vector> using namespace s…
C. Subsequences Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/597/problem/C Description For the given sequence with n different elements find the number of increasing subsequences with k + 1 elements. It is guaranteed tha…
C. Subsequences     For the given sequence with n different elements find the number of increasing subsequences with k + 1 elements. It is guaranteed that the answer is not greater than 8·1018. Input   First line contain two integer values n and k (1…
题目链接: D. Friends and Subsequences time limit per test 2 seconds memory limit per test 512 megabytes input standard input output standard output Mike and !Mike are old childhood rivals, they are opposite in everything they do, except programming. Toda…
[题目链接]:http://codeforces.com/problemset/problem/314/C [题意] 让你从n个元素的数组中选出所有的不同的非递减子数列; 然后计算比这个子数列小的和它的长度一样长的数列的个数; "小"的定义在题目里有说; [题解] 设dp[i]表示以i作为非递减子数列的最后一个数的比它小的数列的个数; 则有递推式 dp[i] = (dp[1]+dp[2]+-+dp[i])*i+i; 写个树状数组,来快速求和就好; 要写出原数组,维护原数组; 不然求dp…
给定一个函数: f([l,r]) = r - l + 1; f(空集) = 0; 即f函数表示闭区间[l,r]的整点的个数 现在给出n个闭区间,和一个数k 从n个区间里面拿出k个区间,然后对这k个区间求并集,并求并集的f函数值 求所有C(n,k)种方案的f函数值之和 1 <= k <= n <= 200000 -10^9 <= l <= r <= 10^9 思路: 思路其实很容易想到 对这些区间缩点 g(i) 表示i这个点代表的区间的点数(即点i实际的点数) s(i)…
原题: Description Mike and !Mike are old childhood rivals, they are opposite in everything they do, except programming. Today they have a problem they cannot solve on their own, but together (with you) — who knows? Every one of them has an integer sequ…
time limit per test2 seconds memory limit per test512 megabytes inputstandard input outputstandard output Mike and !Mike are old childhood rivals, they are opposite in everything they do, except programming. Today they have a problem they cannot solv…
D. Friends and Subsequences 题目连接: http://www.codeforces.com/contest/689/problem/D Description Mike and !Mike are old childhood rivals, they are opposite in everything they do, except programming. Today they have a problem they cannot solve on their o…