- 博客(102)
- 收藏
- 关注
原创 Codeforces Round #210 (Div. 1) problem C Levko and Strings
极好的一道动态规划, 给定一个小写字母的字符串 S, 求其相同长度的子串T,T中恰包含K个子串字典序大于S中相同位置的子串,求T有几种,记 DP[ i ] [ j ][ 2 ] 为 第i个位置为止已有J个子串字典序大于S中相对应为止的子串,最后一维表示相同与否,我在这里用0表示相同,及T[i][=s[i],否则T[i]!=s[i] 我固定位置i, 向前遍历 当到达位置t时, 令 (S[t]
2013-11-12 20:27:09
844
2
原创 LightOj 1334 - Genes in DNA
很好的KMP题目,正反两次KMP (利用DFA的知识概念,统计每个节点的失败节点到根节点的的距离,即代码中的dis数组) ,接下来的问题就迎刃而解了 #include#include#include#include#include#include#include#include#include#include#include#include#include#in
2013-11-09 21:42:25
830
原创 bzoj 1251 简单伸展树
基本操作 翻转 成段加上一个数 求区间最值#include#include#include#include#include#include#include#include#includeusing namespace std;#define L p->ch[0]#define R p->ch[1]#define KeyTree root->ch[1]->ch[0]
2013-10-29 19:09:23
682
原创 ZOJ 2452
笛卡尔树的构造 key 和 aux ( 与treap 相同 , 不同在于aux 是给定的)#include #include #include #include #include #include using namespace std;typedef pair PII;const int maxn = 111111;struct TreeNode { int key,
2013-08-05 18:49:05
493
原创 HDU 4603
求出 每对点 LCA 计算距离,然后 直接走到LCA 对其所影响的分支权值根据奇偶性计算先手所能达到的最大权值#include #include #include #include #include #include using namespace std;typedef long long LL;typedef pair PII;typedef vector VI;con
2013-07-30 18:48:28
795
原创 HDU 4610
搜索加贪心#include #include #include #include #include #include #include #include #include using namespace std;typedef long long LL;typedef pair PII;const double pi = acos(-1.0);const int ma
2013-07-29 01:16:20
561
原创 HDU 4609
实质上是两个多项式相乘注意去重#include #include #include #include #include using namespace std;typedef long long LL;const double pi = acos(-1.0);const int maxn = 271111;const double eps = 1e-6;struct Com
2013-07-29 01:15:27
709
原创 HDU 4608
#include #include #include #include #include #include #include #include using namespace std;typedef vector VI;typedef pair PII;const int maxn = 111111;char s[maxn];int arr[maxn];int main
2013-07-29 01:12:24
455
原创 HDU 4607
#include #include #include #include #include #include #include #include using namespace std;typedef vector VI;typedef pair PII;const int maxn = 111111;struct node { int v, next; no
2013-07-29 01:11:44
525
原创 HDU 4602
EASY PROBLEM#include #include #include using namespace std;typedef long long LL;const int maxn = 111111;const int mod = (int) (1e9 + 7);char s[maxn];int num[maxn];LL POW(LL a, LL b) { L
2013-07-29 01:10:27
418
原创 HDU 4606
根据线段相交 建图 求最短路 二分答案 求最小路径覆盖#include #include #include const int maxn = 311;const double eps = 1e-8;const double INF = 1e50;#define zero(x) (((x)>0?(x):-(x))<eps)templateT min(const T& a, co
2013-07-29 01:09:09
518
原创 HDU 4605
#pragma comment(linker,"/STACK:102400000,102400000") #include #include #include #include #include #include #include using namespace std;typedef vector VI;typedef pair PII;const int maxn =
2013-07-29 01:05:58
469
原创 HDU 4604
//============================================================================// Name : I_love_cherry.cpp// Author : mark// Version :// Copyright : Your copyright notice// Descr
2013-07-29 01:04:52
512
原创 HDU 4601
广搜确定各点深度, 并以此沿广搜顺序将点加入数组 Sequence,序列里的深度逐渐增加,先序遍历树并依次编号,确定每个点及其子树的的编号范围,在Sequence 中二分查找某一深度的点的左右边界(Sequence 中的点的编号其实是逐渐增加的) RMQ 查询最值。至于字典序,则在 遍历树的时候模拟字典树插入,然后求出每个点实际字典序(从根节点到它本身所连成的这个字符串字典序)#pragma
2013-07-29 01:03:14
640
原创 HDU 4600
模拟加贪心#include #include #include #include using namespace std;typedef long long LL;typedef pair PII;const int maxn = 1111;struct node { int area, num, income, next_ripe; node(int area
2013-07-29 00:53:03
512
原创 HDU 4618
#include #include #include #include using namespace std;const int maxn = 311;#define lson l,m,rt<<1#define rson m+1,r,rt<<1|1int a[maxn][maxn];int n, m;bool ok(int i, int j, int k) { int
2013-07-27 14:06:11
528
原创 HDU 4620
/* * test.cpp * * Created on: 2013-7-3 * Author: Administrator */#include #include #include #include #include #include #include using namespace std;typedef vector VI;const int ma
2013-07-27 14:04:43
610
原创 HDU 4619
#include#include#include#include#includeusing namespace std;const int N = 2009;bool vis[N];int cx[N], cy[N], head[N], e, n;struct node { int next, v;} edge[N << 9];inline void add_edge(
2013-07-27 04:09:46
478
原创 HDU 4612
"trajin algorithm" then bfs to determine the longest the distance between any two edge biconnected components#pragma comment(linker,"/STACK:102400000,102400000")#include#include#include#includ
2013-07-27 04:06:57
597
原创 HDU 4617
#include #include #include #include #include using namespace std;const int maxn = 305;const double eps = 1e-6;#define lson l,m,rt<<1#define rson m+1,r,rt<<1|1struct Point { double x, y, z;
2013-07-26 19:02:04
443
原创 HDU 4614
#include #include #include #include #include #include #include using namespace std;#define lson l,m,rt<<1#define rson m+1,r,rt<<1|1typedef pair PII;typedef long long LL;const int maxn = 1
2013-07-26 04:28:05
397
原创 HDU 4611
#include using namespace std;typedef long long LL;templateT gcd(T a, T b) { return b ? gcd(b, a % b) : a;}templateT lcm(T a, T b) { return a / gcd(a, b) * b;}LL cnt, n, a, b;LL cal(int x,
2013-07-25 21:01:55
541
原创 UVA 1426 - Discrete Square Roots
枚举N的因子 合并模线性方程 暴力找答案/* * test.cpp * * Created on: 2013-7-3 * Author: Administrator */#include #include #include #include #include #include #include using namespace std;
2013-07-21 15:09:25
621
原创 SGU 271 双端队列 和 栈 模拟
#include #include #include #include #include #include #include #include using namespace std;deque q;stack st;char op[15];char ss[70000][15];int main() { ios::sync_with_stdio(false); boo
2013-07-19 20:24:58
442
原创 poj 3017
单调队列优化 单调队列 维护 最大值 队列首元素对应的DP 值 为 dp[low-1] + a[q[front]] 其余元素对应的值(设该元素为q[k]) dp[q[k-1]]+a[q[k]]; Treap 维护下最小值就行了。 #include#include#include#include#include#include#include#include#
2013-07-03 22:10:43
471
原创 hdu 4447
多项式 计算 模拟 多项式乘法 和 多项式除法就行了,多项式除法可以参考高精度除法#include#include#include#include#include#include#include#include#include#include#includeusing namespace std;typedef long long LL;const int
2013-06-29 06:10:39
866
原创 HDU 2966 模板题
#include#include#include#include#include#include#includeusing namespace std;typedef long long LL;typedef pair PII;typedef pair pii;#define lson l,m,rt<<1#define rson m+1,r,rt<<1|1const in
2013-06-20 18:56:33
820
原创 G3. Good Substrings
http://codeforces.com/contest/316/problem/G3利用RMQ 求 后缀的前缀在每个串里面的个数二分每个后缀满足要求的最大和最小前缀长度我用了十个后缀数组代码写得有些拖沓#include #include #include using namespace std;#define lson l,m,rt<<1#define rson
2013-06-14 14:21:25
998
原创 POJ 3757
cost=sigma(fi*ci)vi=pi*bi/(pi+bi);sigma(vi)*t=F;fi=vi*t;cost=simga(ci*fi)=sigma(ci*vi*t)=sigma(ci*vi)*t=sigma(ci*vi)*F/(sigma(vi)) 分数规划此题优化后的 二分居然只比迭代 慢20ms 以下是迭代的代码#include#include#i
2013-06-07 17:02:58
588
原创 POJ 3621
#include#include#includeusing namespace std;const int maxn = 1023;const double eps = 1e-3;typedef long long LL;struct node { int v, next; double w; int t; node() { } node(int v, int next,
2013-06-07 15:45:49
381
原创 HDU 4189
#include#include#include#include#include#includeusing namespace std;const int maxn = 151111;const int INF = 2147483647;typedef long long LL;typedef pair pii;#define lson l,m,rt<<1#define r
2013-06-06 14:00:05
586
原创 HDU 3486
#include #include const int N = 1111;char buf[N], op[N];int lch[N], rch[N];int h[N];int build(char s[], int x, int y, int lch[], int rch[], char op[], int &nc) { int i, u, c1, c2; int p = 0;
2013-06-04 13:17:17
736
原创 HDU 4565 So Easy!
#include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std;#define clr(a,v) memset(a,v,sizeof(a))
2013-06-02 21:44:50
788
原创 HDU Connections between cities
#include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std;#define clr(a,v) memset(a,v,sizeof(a))
2013-06-02 21:26:27
438
原创 HDU 4196 Remoteland
#include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std;typedef long long LL;typedef unsigned long long
2013-05-31 20:30:08
526
原创 POJ System
/*ID: BryatnMarkLANG: JAVATASK: AC */import java.util.*;import java.io.*;import java.math.*;import java.util.*;public class Main { public static void main(String args[]) throws Exception {
2013-05-31 08:29:34
442
原创 light oj 1274 - Beating the Dataset
#include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std;typedef long long LL;typedef unsigned long long
2013-05-30 21:31:36
716
1
原创 URAL 1306. Sequence Median
#include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std;typedef long long LL;typedef unsigned long long
2013-05-30 16:50:39
490
原创 LightOJ 1342 - Aladdin and the Magical Sticks
#include #include #include #include #include #include #include #include #include #include #include #include using namespace std;typedef long long LL;typedef unsigned long long ULL;typed
2013-05-30 12:57:58
962
原创 URAL 1447. Portkey Network
#include #include #include #include #include #include #include #include #include #include #include #include using namespace std;typedef long long LL;typedef unsigned long long ULL;typed
2013-05-29 16:50:42
1182
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人