摘要: 1 ans = dp[1] = 1; 2 for (int i = 1; i d[l]) { 12 d[++l] = b[i]; 13 } else { 14 int k = lower_bound(d + 1, d + l + 1, b[i]) - d; 15 d[k] = b[i]; 16 ... 阅读全文
posted @ 2019-07-15 22:07 Snow_in_winer 阅读(149) 评论(0) 推荐(0) 编辑
摘要: 1 struct node { 2 int u, v, w; 3 4 bool operator<(const node &b) const { 5 return w < b.w; 6 } 7 }a[M]; 8 9 int find(int x) { 10 if (x == f[x]) { 11 return ... 阅读全文
posted @ 2019-07-15 22:06 Snow_in_winer 阅读(140) 评论(0) 推荐(0) 编辑
摘要: 1 for (int i=1;i d[l]) { 23 d[++l] = b[i]; 24 } else { 25 int k = lower_bound(d + 1, d + l + 1, b[i]) - d; 26 d[k] = b[i]; 27 } 28 } 29 pr... 阅读全文
posted @ 2019-07-15 22:06 Snow_in_winer 阅读(131) 评论(0) 推荐(0) 编辑
摘要: 1 #include<cstring> 2 #include<stack> 3 #include<cstdio> 4 using namespace std; 5 6 const int N=400010; 7 char c[N]; 8 int n,m,i,j,next[N],l; 9 stack< 阅读全文
posted @ 2019-07-15 22:05 Snow_in_winer 阅读(130) 评论(0) 推荐(0) 编辑
摘要: 1 int linker[MAXN * 2]; 2 bool used[MAXN * 2]; 3 4 bool dfs(int u) { 5 for (int i = h[u]; i; i = e[i].n) { 6 int v = e[i].t; 7 if (!used[v]) { 8 used[v] = 1; ... 阅读全文
posted @ 2019-07-15 22:04 Snow_in_winer 阅读(191) 评论(0) 推荐(0) 编辑
摘要: 1 int gcd(int a,int b) { 2 if (!b) { 3 return a; 4 } 5 return gcd(b, a % b); 6 } 阅读全文
posted @ 2019-07-15 22:04 Snow_in_winer 阅读(109) 评论(0) 推荐(0) 编辑
摘要: 1 for (int k=1;i<=n;i++){ 2 for (int i=1;i<=n;i++){ 3 for (int j=1;j<=n;j++){ 4 f[i][j]=min(f[i][j],f[i][k]+f[k][j]); 5 } 6 } 7 } 阅读全文
posted @ 2019-07-15 22:03 Snow_in_winer 阅读(119) 评论(0) 推荐(0) 编辑
摘要: /* 裴蜀定理: a,b d=(a,b) >ax+by=d=(a,b)*/int exgcd(int a,int b,int &x,int &y) { if (!b) { x = 1;y = 0;return a; } int d = exgcd(b, a % b, y, x); y -= a / 阅读全文
posted @ 2019-07-15 22:02 Snow_in_winer 阅读(119) 评论(0) 推荐(0) 编辑
摘要: 1 /* 2 算术基本定理 3 n=p1^a1*p2^a2*p3^a3*...*pn^an 4 5 约数个数:(p1+1)*(p2+1)*(p3+1)*..*(pn+1) 6 phi(n)=n*(1-1/p1)*(1-1/p2)*...*(1-1/pn) 7 8 欧拉数:1-n中与n互质的数的个数 9 phi(n)=n*(1-1/p1)*(1-1/p2)*...... 阅读全文
posted @ 2019-07-15 22:01 Snow_in_winer 阅读(129) 评论(0) 推荐(0) 编辑
摘要: const int maxn=1e5+7; const int maxm=1e5+7; const int inf=0x3f3f3f3f; struct Dinic { struct Edge { int next, f, to; } e[maxm]; int head[maxn], dep[maxn], tol, ans; int cur[max... 阅读全文
posted @ 2019-07-15 22:00 Snow_in_winer 阅读(140) 评论(0) 推荐(0) 编辑
摘要: void Dijkstra(int u) { memset(vis,0,sizeof(vis)); for(int t=1;t,vector >,greater > >q1; int dijkstra(int s,int t) { memset(d,inf,sizeof(d)); memset(v,0,sizeof(v)); d[s] = 0; q1.push(make_... 阅读全文
posted @ 2019-07-15 21:58 Snow_in_winer 阅读(135) 评论(0) 推荐(0) 编辑
摘要: 1 int lowbit(int x) { 2 return x & -x; 3 } 4 5 void change1(int x,int d) //单点修改 6 { 7 for (int i = x; i <= n; i += lowbit(i)) { 8 c[i] += d; 9 } 10 } 11 12 int sum1... 阅读全文
posted @ 2019-07-15 21:57 Snow_in_winer 阅读(109) 评论(0) 推荐(0) 编辑
摘要: 问题描述: 给定n个整数(可能有负数)组成的序列a1,a2,...,an,求该序列的最大子段和。如果所有整数都是负数,那么定义其最大子段和为0。 思路: 1.暴力枚举左端点右端点然后求和.O(n^3) 2.预处理前缀和,枚举左端点右端点.O(n^2) 3.类似DP 1 for (int i = 0; 阅读全文
posted @ 2019-07-15 21:13 Snow_in_winer 阅读(183) 评论(0) 推荐(0) 编辑
摘要: 题目描述 You are given a string S of length N. Among its subsequences, count the ones such that all characters are different, modulo 109+7. Two subsequenc 阅读全文
posted @ 2019-07-15 14:22 Snow_in_winer 阅读(209) 评论(0) 推荐(0) 编辑
摘要: 题目描述: There are N stones arranged in a row. The i-th stone from the left is painted in the color Ci.Snuke will perform the following operation zero or 阅读全文
posted @ 2019-07-15 14:16 Snow_in_winer 阅读(226) 评论(0) 推荐(0) 编辑