自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(595)
  • 收藏
  • 关注

原创 leetcode 175. Combine Two Tables

题意是选出两个表有相同PersonId的信息。考察SQL LEFT JOIN关键字。SQL LEFT JOIN 关键字LEFT JOIN 关键字会从左表 (table_name1) 那里返回所有的行,即使在右表 (table_name2) 中没有匹配的行。LEFT JOIN 关键字语法SELECT column_name(s)FROM table_name1LEFT J

2017-05-02 09:57:18 487

原创 leetcode 2. Add Two Numbers

/** * Definition for singly-linked list. * public class ListNode { * int val; * ListNode next; * ListNode(int x) { val = x; } * } */public class Solution { public ListNode addT

2017-01-31 14:49:06 390

原创 leetcode 2. Add Two Numbers

/** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {} * }; */class Solution {public: ListNode* ad

2017-01-31 14:11:00 355

原创 HDOJ 6012 Lotus and Horticulture

明显温度可以离散化,最多10^6个点,由于只要求最终结果,不需要动态更新,所以用前缀和就可以了。比赛的时候写了线段树,麻烦了。#include using namespace std;typedef long long LL;map mpp;int n;void work(){ mpp.clear(), mpp[0] = 0; scanf("%d", &n); for(i

2017-01-23 13:08:33 400

转载 Bloom Filter

转载自焦萌http://blog.csdn.net/jiaomeng/article/details/1495500Bloom Filter概念和原理Bloom Filter是一种空间效率很高的随机数据结构,它利用位数组很简洁地表示一个集合,并能判断一个元素是否属于这个集合。Bloom Filter的这种高效是有一定代价的:在判断一个元素是否属于某个集合时,有可能会把不属于这个集合的元

2017-01-01 15:39:21 371

原创 BestCoder 2nd Anniversary

1001 Oracle先记录 0−90-90−9这101010个数字分别有多少个。不难看出,最小的一个存在的数字和其余的数字降序排列的相加就是答案,但是最小的那个数字不能是000,因为题面上说明是正整数。将这两个数加起来时,注意处理进位问题。考虑无解的情况,即一串数字中仅存在111个非000数字或不存在。(PS.这道题目原本的时限是1s1s1s,考虑到题目的难度和评测机的问题,开了4s

2016-07-23 18:55:33 739

原创 【DP】 BZOJ 3437: 小P的牧场

斜率优化一下就行了。。。#include using namespace std;typedef long long LL;const int maxn = 1000005;LL a[maxn], H[maxn], s[maxn], f[maxn];int q[maxn], n, m;LL getfz(int j2, int j1){ return f[j1] - f[j

2015-11-09 19:46:02 869

原创 【DP】 BZOJ 3675: [Apio2014]序列分割

推出公式以后就可以斜率dp优化了。。。#include using namespace std;typedef long long LL;const int maxn = 100005;LL t1[maxn], t2[maxn];LL s[maxn];LL *f, *g;int q[maxn];int n, m;LL getfz(int j2, int j1){ r

2015-11-06 21:28:07 551

原创 【DP】 HDOJ 3507 Print Article

斜率dp水题。。。#include using namespace std;typedef long long LL;const int maxn = 500005;int f[maxn];int s[maxn];int q[maxn];int n, m;int getfz(int j2, int j1){ return (f[j1] + s[j1] * s[j1])

2015-11-06 20:31:30 550

原创 【DP】 cf 321E

用四边形优化一下dp即可。。。。#include using namespace std;typedef long long LL;const int maxm = 808;const int maxn = 4004;const int INF = 0x3f3f3f3f;int f[maxm][maxn];int s[maxm][maxn];int a[maxn][maxn

2015-11-02 14:18:04 488

原创 【DP】 HDOJ 2974 Counting heaps

推出dp公式然后就可以做了。。#include #include #include #include #include using namespace std;typedef long long LL;#define mp(x, y) make_pair(x, y)const int maxn = 500005;queue q;int fa[maxn];int in[

2015-10-30 13:55:51 540

原创 【DP】 cf 487B

用队列转移dp即可。。。#include using namespace std;typedef long long LL;#define mp(x, y) make_pair(x, y)const int maxn = 100005;int P[maxn];int a[maxn];int dp[maxn];int st1[maxn][20];int st2[maxn][

2015-10-29 19:51:40 559

原创 【DP】 cf 486D

考虑每个点作为最小的权值点。。。然后dp#include using namespace std;typedef long long LL;const int mod = 1000000007;const int maxn = 2005;const int maxm = 4005;struct Edge{ int v; Edge *next;}E[maxm], *H[m

2015-10-29 16:48:02 513

原创 【DP】 cf 590D Top Secret Task

#include using namespace std;typedef long long LL;const int maxn = 155;const int INF = 0x3f3f3f3f;int dp[maxn][maxn * maxn];void update(int &x, int y){ if(x > y) x = y;}void work(){ int

2015-10-28 14:25:33 1072

原创 Codeforces Round #325 (Div. 2) D. Phillip and Trains

水题,bfs一下即可。。。#includeusing namespace std;typedef long long LL;#define mp(x, y) make_pair(x, y)const int maxn = 105;queue >q;int vis[5][maxn];char g[5][maxn];int n, m;bool check(int x, in

2015-10-13 17:47:24 426

原创 Codeforces Round #325 (Div. 2) E. Alice, Bob, Oranges and Apples

模拟一下发现和gcd一样。。。于是按gcd模拟就好了。。。#includeusing namespace std;typedef long long LL;void work(){ LL a, b; scanf("%I64d%I64d", &a, &b); if(__gcd(a, b) != 1) { printf("Impossible\n"); return; }

2015-10-13 14:59:49 635

原创 Gym 100726B Common Subexpression Elimination

递归下降建树,然后对每个节点编号....一个节点该节点的hash值和左儿子的编号和右儿子的编号是唯一的....用map查询#include using namespace std;typedef long long LL;const int maxn = 800000;struct node{ int val, id, is; string s; node *ch[2];

2015-10-09 16:54:44 649

原创 线段树 FZU 2201 序列操作

把gcd转化成差值...然后建立两颗线段树....#include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std;typedef long lon

2015-10-09 15:41:07 640

原创 矩阵快速幂 CodeForces - 582B Once Again...

建出转移矩阵...然后做矩阵快速幂就行了....#include using namespace std;typedef long long LL;const int maxn = 105;const int INF = 0x3f3f3f3f;int mat[maxn][maxn];int res[maxn][maxn];int mid[maxn][maxn];int a[

2015-10-05 20:34:15 1305

原创 HDOJ 5498 Tree

容斥一下然后生成树计数就行了....#include using namespace std;typedef long long LL;const int maxn = 105;int a[maxn][maxn];LL c[maxn][maxn];int base, n, m, q;int det(int n){ int ans = 1, i, j, k;

2015-10-04 20:06:40 419

原创 线段树 CodeForces 580E

线段树上的hash...#include using namespace std;typedef long long LL;#define lson o << 1, L, mid#define rson o << 1 | 1, mid+1, R#define ls o << 1#define rs o << 1 | 1const int mod = 1e9+7;const i

2015-10-03 18:29:06 629

原创 mobius HDOJ 5468 Puzzled Elena

dfs遍历树+莫比乌斯反演..#include using namespace std;typedef long long LL;const int maxn = 100005;const int maxm = 200005;struct Edge{ int v; Edge *next;}E[maxm], *H[maxn], *edges;int not_prime[

2015-10-02 19:37:12 475

原创 树链剖分 JAG Summer 2012 Day 4 D Do use segment tree

树链剖分裸题....#include using namespace std;typedef long long LL;#define lson o << 1, L, mid#define rson o << 1 | 1, mid+1, R#define ls o << 1#define rs o << 1 | 1const int INF = 0x3f3f3f3f * 2;

2015-10-02 18:40:43 407

原创 DP HDOJ 5471 Count the Grid

先转化成了离散网格图,然后状态dp即可....#include using namespace std;typedef long long LL;#define mp(x, y) make_pair(x, y)const int maxn = 100;const int mod = 1e9+7;struct line{ int x1, y1, x2, y2, v; lin

2015-10-01 20:01:21 479

原创 BZOJ 2440: [中山市选2011]完全平方数

二分,然后用莫比乌斯做就行了...#include using namespace std;typedef long long LL;const int maxn = 50005;int not_prime[maxn];int prime[maxn];int mu[maxn];int K, p_cnt;void Init(){ mu[1] = 1; p_cnt =

2015-09-30 15:06:24 602

原创 DP HDOJ 5492 Find a path

化简公式然后递推....#include using namespace std;typedef long long LL;const int INF = 0x3f3f3f3f;int dp[33][33][60 * 33];int g[33][33], n, m;void update(int &x, int y){ if(x > y) x = y;}void w

2015-09-29 20:00:14 406

原创 HDOJ 5483 Nux Walpurgis

先做出最小生成树,然后对每个点dfs判断树边是否可删.....#include using namespace std;typedef long long LL;const int maxn = 3005;const int maxm = 6005;const int INF = 0x3f3f3f3f;struct Edge{ int v; Edge *next;}E[

2015-09-29 14:51:43 414

原创 DP Codeforces Round #322 (Div. 2) F. Zublicanes and Mumocrates

树形dp,记录一下根节点的状态即可...#include using namespace std;typedef long long LL;const int maxn = 5005;const int maxm = 10005;const int INF = 0x3f3f3f3f;struct Edge{ int v; Edge *next;}E[maxm], *H[

2015-09-28 21:40:39 626

原创 HDOJ 5487 Difference of Languages

记dp[i][j] 代表走到了第一个dfa的i号节点,走到了第二个自动机的j号节点.....然后就可以转移了......#include using namespace std;typedef long long LL;const int maxn = 1005;struct node{ int s1, s2, pre, tran; node(int s1 = 0, int

2015-09-28 15:17:23 436

原创 HDOJ 5469 Antonidas 树分治

经典的树分治,找字符串用hash找就行了....#include using namespace std;typedef long long LL;#define mp(x, y) make_pair(x, y)const int maxn = 10005;const int maxm = 20005;const int INF = 0x3f3f3f3f;const int m

2015-09-28 13:12:10 416

原创 [DP] HDOJ 5456 Matches Puzzle Game

数位DP...#include using namespace std;typedef long long LL;LL dp[505][2][2][2];int cnt[] = {6, 2, 5, 5, 4, 5, 6, 3, 7, 6};int mod;void add(LL& a, LL b){ a += b; if(a > mod) a -= mod;}LL

2015-09-25 13:28:45 386

原创 [半平面交] HDOJ 5462 Manors

很容易就能看出半平面交的公式...但是比赛的时候这题看都来不及看...#include using namespace std;typedef long long LL;const int maxn = 1005;const double eps = 1e-7;struct Point{ double x, y; Point(double x = 0, double y =

2015-09-23 20:00:30 512

原创 [网络流] HDOJ 5457 Hold Your Hand

建出字典树,然后做最小割就行了...#include using namespace std;typedef long long LL;const int maxn = 5005;const int maxm = 400005;const int INF = 0x3f3f3f3f;struct Edge{ int v, c, next; Edge() {} Edge(i

2015-09-23 18:20:45 497

原创 [线段树] HDOJ Excited Database

把一个矩阵化成3个三角形容斥,然后用等差线段树就可以做了...#include using namespace std;typedef long long LL;#define now o, L, R, tree#define lson o << 1, L, mid, tree#define rson o << 1 | 1, mid+1, R, tree#define ls o

2015-09-21 20:13:26 417

原创 hihocoder #1236 : Scores

高维bitset....#include using namespace std;typedef long long LL;const int maxn = 50005;struct node{ int val, id; node(int val = 0, int id = 0) : val(val), id(id) {} bool operator < (const no

2015-09-21 14:28:32 716

原创 [动态树] HDOJ 5467 Clarke and hunger games

按时间点建树,然后递归实现LCT的可持久化....#include using namespace std;typedef long long LL;#define mp(x, y) make_pair(x, y)const int maxn = 300005;const int maxm = 300005;const int INF = 0x3f3f3f3f;const in

2015-09-21 10:07:57 529

原创 HDOJ 5458 Stability

由于没有看到图在任意时刻都是连通的..这一条件..于是只好打了动态树..#include using namespace std;typedef long long LL;const int maxn = 30005;const int maxm = 400005;struct Node *null;struct Node{ Node *fa, *ch[2]; int s

2015-09-19 18:44:40 416

原创 【NTT】 ZOJ 3874 Permutation Graph

推出公式以后分治ntt优化即可。。。#include using namespace std;typedef long long LL;const int maxn = 100005;const int maxm = 300005;const int mod = 786433;LL a[maxm], b[maxm], c[maxm];LL f[maxn], dp[maxn

2015-09-18 13:06:22 576

原创 【NTT】 HDOJ 5279 YJC plays Minecraft

推出公式以后就可以ntt了。。。#include using namespace std;typedef long long LL;const int mod = 998244353;const int maxn = 700005;LL dp[100005],dp2[100005];LL a[maxn], b[maxn], c[maxn], xp[maxn];LL f[100

2015-09-17 18:21:27 415

原创 【矩阵快速幂】 HDOJ 5434 Peace small elephant

对每一列状态压缩,然后矩阵加速即可。。。#include using namespace std;typedef long long LL;const int mod = 1e9+7;const int maxn = 130;LL mat[maxn][maxn];LL mid[maxn][maxn];LL res[maxn][maxn];int n, m;void ca

2015-09-16 14:04:13 338

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除