自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

禅境花园

http://www.xiang578.com

  • 博客(30)
  • 资源 (1)
  • 收藏
  • 关注

原创 Educational Codeforces Round 12 E. Beautiful Subarrays【字典树】

/* ***********************************************Author :MaltubEmail :xiang578@foxmail.comBlog :htttp://www.xiang578.top************************************************ */#

2016-04-30 09:07:57 436

原创 hdu2870 Largest Submatrix 【dp】

hdu1505升级版#include<bits/stdc++.h>using namespace std;const int N=1024;int g[N][N],r[N],h[N][N],l[N];char s[N][N],st[N];int n,m;int fcn(int k){ if(k==0) { for(int i=1; i<=n; i++)

2016-04-29 17:57:43 361

原创 hdu1300 Pearls 【dp】

没有看到限制条件,品质越高的价格就越贵,导致想了一个多月都写不出来。#include<bits/stdc++.h>using namespace std;int a[1024],p[1024],dp[1024],sum[1024];int main(){ int _,n; scanf("%d",&_); while(_--) { scanf("%

2016-04-28 19:10:53 463

原创 zoj3715 Kindergarten Election 【枚举+贪心】

不枚举要几票获胜根本想不同。 枚举获胜需要的票数(最少是2),然后自己这也票投给谁都没有影响。#include<bits/stdc++.h>using namespace std;struct node{ int f,c,id;} p[1024],u[1024];int cmp1(node a,node b){ if(a.f==b.f) return a.

2016-04-27 18:08:09 627

原创 zoj3946 Highway Project 【最短路】

比赛的时候,以为是最短路+最小生成树,最后wa到死。 出来后才知道是最短路。#include<bits/stdc++.h>using namespace std;const int N=2e5+10;const long long inf=0x3fffffffffffffff;struct node{ int u,v; long long d,c;} G[N];vec

2016-04-25 12:27:13 503

原创 nbut1457 Sona 【莫队算法+离散化】

map离散化会超时答案会爆int,long long 输出控制为%I64d#include<algorithm>#include<iostream>#include<string.h>#include<stdio.h>#include<math.h>#include<map>using namespace std;typedef long long ll;const int N=

2016-04-20 14:14:52 479

原创 bzoj 2038: [2009国家集训队]小Z的袜子(hose) 【莫队算法】

#include<algorithm>#include<iostream>#include<string.h>#include<stdio.h>#include<math.h>using namespace std;typedef long long ll;const int N=50000+10;struct node{ int l,r,id;}Q[N];int pos

2016-04-20 12:38:21 335

原创 poj2155 Matrix 【二维树状数组】

#include <stdio.h>#include <string.h>#include <iostream>#include <algorithm>#include <vector>#include <queue>#include <set>#include <map>#include <string>#include <math.h>#include <stdlib.h>

2016-04-20 09:05:31 251

原创 cf617 E. XOR and Favorite Number【莫队算法】

UESTCACM-莫队算法讲解视频#include<bits/stdc++.h>using namespace std;typedef long long ll;const int M=1e6;const int N=1<<20;struct node{ int l,r,id;}Q[M];ll ans,p[M],flag[N];int a[N],pos[N];int cmp(n

2016-04-18 10:55:17 841

原创 hdu5667 Sequence 【矩阵快速幂+欧拉函数降次】

多写几项就可以发现每一项都是a的次数有关,然后可以构造一个矩阵,求他的快速幂,这个过程中可以用欧拉函数降幂,即中途对p-1取模。 然后还有一个细节,如果a%p==0的话,要特判为0。/* ***********************************************Author :MaltubEmail :xiang578@foxmail.com

2016-04-17 07:52:14 682

原创 hdu 1823 Luck and Love 【二维线段树】

#include<cstdio>#include<algorithm>#include<cstring>using namespace std;const int inf=1<<30;const int maxn=5000+10;const double eps=1e-6;struct IntervalTree2D{ int mx[500][maxn],n,m; int

2016-04-16 15:37:10 335

原创 uva11297 Census 【二维线段树】

#include<cstdio>#include<algorithm>#include<cstring>using namespace std;const int inf=1<<30;const int maxn=2000+10;struct IntervalTree2D{ int mx[maxn][maxn],mi[maxn][maxn],n,m; int xo,xle

2016-04-16 14:17:49 422

原创 Educational Codeforces Round 8 F. Bear and Fair Set【最大流】

刚开始超时的建图 1. 先有s和t,s和余数建边,流量是n/5。 2. 对于i从1到b,i和余数建边,流量是1,将i和不超过i的最大限制建边,流量是1。 3. 之后再将限制之间相互建边。 4. 毫无疑问这个是超时的,而且也是不正确的,题目中每个限制区间是严格取的看了题解以后 1. 我第一写的1到b的建边其实是没有太大意义的 2. 之后只需要将数轴分区间就好了,比如限制是[1,n1],

2016-04-16 11:07:01 435

原创 FZU2143 Board Game 【费用流+棋盘模型】

#include<stdio.h>#include<string.h>#include<vector>#include<queue>#include<algorithm>using namespace std;const int N=100;const int inf=0x7fffffff;struct Edge{ int from,to,cap,flow,cost;};

2016-04-15 20:45:09 564

原创 zoj3705 Applications 【简单模拟】

#include<bits/stdc++.h>using namespace std;const double eps=1e-6;struct node{ string name; double pts;}p[1024];double a[10000];int b[1000];int isprime(int x){ if(x==1) return 0;

2016-04-13 12:50:27 536 1

原创 zoj3929 Deque and Balls 【找规律】

比赛的时候以为是找逆序数,浪费了两个小时。 1. 首先不考虑相等的情况,当放入第k个时,第1、2、3、4、5。。。个数对他的贡献分别是1、1、2、4、8、16。。。即放入第k个数时,结果增加2的k-2次, 2. 考虑相等时的情况,假设第i个数相等,那么只有i为第一个或者为最后一个才有影响,第i+1到k-1的数字排列方式唯一,即将结果减去2的i-2,维护一个数组记录相同需要减去的值即可#inclu

2016-04-13 12:02:32 472

原创 Educational Codeforces Round 11 D. Number of Parallelograms 【pair的使用】

平行四边形对角线两点连线的中点相同,利用这个性质可以快速计算。#include<bits/stdc++.h>using namespace std;map<pair<int,int>,int>mp;int x[2048],y[2048];int main(){ int n,i,j; long long ans; scanf("%d",&n); for(i=0;

2016-04-13 08:57:25 261

原创 zoj3933 Team Formation 【费用流】

可能乱用模板会超时。。。#include<stdio.h>#include<string.h>#include<vector>#include<queue>#include<algorithm>using namespace std;const int N=5024;const int inf=0x7fffffff;struct Edge{ int from,to,cap,

2016-04-11 13:06:22 573

原创 hdu4549 M斐波那契数列 【矩阵快速幂+快速幂+欧拉函数降次】

#include<stdio.h>#include<string.h>#include<algorithm>using namespace std;typedef long long ll;const ll m=1000000007;const ll mt=m-1;ll pow_mod(ll a,ll n){ if(n==0) return 1; ll x=pow_

2016-04-09 08:24:55 448

原创 hdu3400 Line belt 【三分搜索】

三分搜索处理的是凹凸函数求最值,一般想法是由l和r求出mid,再由mid和r求出mmid,用mid和mmid更新l和r。 本题三分ab上的点x,固定x去三分cd上的y点,x和y的坐标由比例得到。不知道为什么本题计算距离开方时要加上一个eps。#include<bits/stdc++.h>using namespace std;const double eps=1e-6;struct poin

2016-04-08 17:32:56 346

原创 Codeforces Alpha Round #21 C. Stripe 2 【DP+标记想法】

注意答案会超过int范围#include<bits/stdc++.h>using namespace std;typedef long long ll;ll a[100000+5],sum[100000+5];int main(){ int n,i; ll ans,x; memset(sum,0,sizeof(sum)); scanf("%d",&n);

2016-04-08 12:28:26 315

原创 FZU2101 大三的美好时光 【离散化+dp】

时间的范围比较大,但是最多只有20W点,所以可以选择离散化离散化时,可以lower_bound重新搜索标号之后,按结束时间从小到大排序,再进行dp?#include<stdio.h>#include<string.h>#include<math.h>#include<algorithm>using namespace std;const int N=100000+10;struct

2016-04-07 20:06:58 312

原创 hdu1978 How many ways

#include<bits/stdc++.h>using namespace std;const int mod=10000;int g[120][120],n,m,ans[120][120],vis[120][120];/*void dfs(int x,int y,int cnt,int sum){ if(cnt==0) return ; if(x+1<=n) {

2016-04-06 17:59:57 248

原创 zoj3537 Cake 【凸包+最优三角形划分】

判断输入的点能不能组成凸包(即所有点都要是凸包的顶点)然后就是求最优三角形划分问题,也就是区间dp感觉这种区间dp还是记忆化搜索写起来比较方便记忆化搜索#include<bits/stdc++.h>using namespace std;const int inf=0x3fffffff;int top,s[10024];struct data{ int x,y;} p[100

2016-04-06 11:29:31 959

原创 PAT-A-1051 Pop Sequence 【栈】

1051. Pop Sequence (25)Given a stack which can keep M numbers at most. Push N numbers in the order of 1, 2, 3, …, N and pop randomly. You are supposed to tell if a given sequence of numbers is a possib

2016-04-05 21:30:16 1737

原创 hdu1160 FatMouse's Speed 【最长下降子序列+输出】

本来想写nlogn,想错了,一直过不了,只能上暴力的。//#include<bits/stdc++.h>#include<stdio.h>#include<vector>#include<string.h>#include<algorithm>using namespace std;const int N=1024;int f[N],a[N],d[N];struct node{

2016-04-05 16:27:12 1236

原创 cf19B. Checkout Assistant 【01 背包】

将所有t[i]加1,就是求容量为n的01背包问题.#include<bits/stdc++.h>using namespace std;typedef long long ll;int t[2048];ll c[2048];ll dp[2048];ll ans;int main(){ int n; scanf("%d",&n); for(int i=0;i<n;

2016-04-03 22:19:23 506

原创 hdu1421 搬寝室 【线性DP】

忍住没有搜题解,零零碎碎想了两个星期才想出来怎么DP。#include<bits/stdc++.h>using namespace std;typedef long long ll;const ll inf=0x7fffffff;ll dp[2048][2048],c[2048],ans;int main(){ int i,j,n,k; while(~scanf("%d%d

2016-04-03 21:29:08 269

原创 hdu1007 Quoit Design【平面最近点对+分治】

算法课上分治算法的例题,大概思路是: 1. 对x轴坐标进行升序排列,考虑区间(l,mid)和(mid+1,r)里面的最近点对。 2. 考虑点对出现在(l,mid)和(mid+1,r)时,对y轴坐标进行升序排列。之后考虑符合条件的两边的点合并对y轴进行归并排序法#include<stdio.h>#include<algorithm>#include<math.h>using namespace

2016-04-03 16:19:32 310

原创 Educational Codeforces Round 1 C. Nearest vectors 【极角排序atan2法】

题目链接 atan2(y,x)计算点(x,y)和x正半轴的夹角(弧度制)。#include<bits/stdc++.h>using namespace std;typedef long double ldb;const ldb pi=3.1415926535897932384626433832795028841971;struct node{ int id; ldb arc

2016-04-03 11:11:17 345

图论算法理论、实现及应用--王桂平--PPT--源代码--例图

图论算法理论、实现及应用--王桂平配套使用

2015-07-20

空空如也

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

TA关注的人

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