自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 Tyvj 1057 金明的预算方案 树形dp

#include #include #include #include using namespace std; const int N =32005; const int M =62; vectorg[M]; struct node{ int cost; int val; }s[M]; int dp[M][N]; void dfs(int rt,int m){ if(m==0){ r

2014-04-11 18:32:59 868

原创 Tyvj 1052 没有上司的舞会 树形dp

#include #include #include #include using namespace std; const int N =6005; int val[N]; int dp[N][2]; vectorg[N]; bool flag[N]; void dfs(int rt){ if(g[rt].size()==0){ dp[rt][1]=val[rt]; dp[rt][0

2014-04-11 18:32:14 598

原创 Tyvj 1051 选课 树形dp

#include #include #include #include using namespace std; const int N =310; int val[N]; vectorg[N]; int dp[N][N]; void dfs(int rt,int m){ if(m==0) { return; } for(int h=0;h<g[rt].size();h++){ i

2014-04-11 18:30:06 987

原创 hdu 2412 Party at Hali-Bula 树形dp

#include #include #include #include #include #include using namespace std; mapma; map::iterator na; const int N =210; char str1[N],str2[N]; int cnt; int dp[N][2]; bool uniq[N][2]; int find(string str)

2014-04-08 23:47:41 509

原创 hdu 1054 Strategic Game 树形dp

#include #include #include #include using namespace std; const int N =1505; vectorg[N]; bool flag[N]; int dp[N][2]; void dfs(int root){ if(g[root].size()==0){ dp[root][0]=0; dp[root][1]=1; ret

2014-04-08 22:21:56 437

原创 Vijos P1250最勇敢的机器人 dp 分组背包

#include #include #include #include using namespace std; const int N =1010; struct node{ int val; int cost; }s[N]; int set[N]; int dp[N]; vectorg[N]; bool flag[N]; int temp[N]; int find(int x){ int

2014-04-08 00:30:35 553

原创 hdu 3535 AreYouBusy dp

#include #include #include #include using namespace std; const int inf =-0x7f7f7f7f; const int N =110; struct node{ int cost; int val; }; vectorg[N]; int dp[N][N]; int flag[N]; int main(){ int n,m;

2014-04-07 23:48:34 451

原创 hdu 3033 I love sneakers! dp

#include #include #include #include using namespace std; const int N=105; const int M=10005; const int inf=-0x7f7f7f7f; struct node{ int val; int cost; }; vectorg[N]; int dp[N][M]; int main(){

2014-04-07 00:22:25 454

原创 hdu 3496 Watch The Movie dp

#include #include #include using namespace std; const int inf=-0x7f7f7f7f; const int N =110; const int M =1010; struct node{ int val; int cost; }s[N]; int dp[M][N]; int main(){ int t; int n,m,l;

2014-04-05 23:13:58 492

原创 hdu 2844 Coins dp

#include #include #include using namespace std; const int N =110; const int M =100005; int m; struct node{ int num; int val; }s[N]; int dp[M]; void CompletePack(int cost,int val){ for(int i=cost;i

2014-04-05 22:14:03 376

原创 poj 2828 Buy Tickets 线段树 单点更新

#include #include #include using namespace std; const int N =200005; int maxn[N<<2]; struct node{ int id; int val; }s[N]; int a[N]; void build(int l,int r,int rt){ if(l==r){ maxn[rt]=1; return;

2014-04-05 18:37:03 463

原创 hdu 2795 Billboard 线段树 单点更新

#include #include #include using namespace std; const int N =200005; int maxn[N<<2]; int h,w; void build(int l,int r,int rt){ if(l==r){ maxn[rt]=w; return; } int mid=(l+r)>>1; build(l,mid,rt<<

2014-04-04 15:57:34 411

原创 Tyvj 1056 能量项链 dp

#include #include #include using namespace std; const int N =210; int a[N]; int dp[N][N]; int main(){ int n; while(scanf("%d",&n)!=EOF){ for(int i=0;i<n;i++){ scanf("%d",&a[i]); a[i+n]=a[i];

2014-04-03 19:50:40 563

原创 hdu 2665 Kth number 区间第K大值 划分树

#include #include #include using namespace std; const int N =100015; int tree[30][N]; int a[N]; int cnt[30][N]; void build(int l,int r,int dep){ if(l==r) return; int mid=(l+r)>>1; int num=

2014-04-02 21:37:06 626

原创 poj 2388 Who's in the Middle 第K大的数 线性时间选择

#include #include #include using namespace std; const int N =10005; int a[N]; inline void Swap(int &a,int &b){ int temp=a; a=b; b=temp; } int partion(int l,int r){ int temp=a[l]; while(l<r){ w

2014-04-02 18:09:23 664

原创 hdu 2697 WOJ dp

#include #include #include using namespace std; const int N =110; int a[N]; int dp[N][N]; int main(){ int t; int n,m; scanf("%d",&t); while(t--){ scanf("%d%d",&n,&m); for(int i=1;

2014-04-02 00:27:45 582

原创 hdu 1394 Minimum Inversion Number 逆序数 线段树&归并排序

#include #include #include using namespace std; #define N 5005 int a[N]; int sum[N<<2]; void build(int l,int r,int rt){ if(l==r){ sum[rt]=0; return; } int mid=(l+r)>>1;

2014-04-01 23:38:43 446

原创 hdu 1754 I Hate It 线段树 单点更新

#include #include #include using namespace std; #define N 200001 int maxn[N<<2]; int x; void build(int l,int r,int rt){ if(l==r){ scanf("%d",&x); maxn[rt]=x; return; } int mid=(l+r)>>1; buil

2014-04-01 09:47:54 404

原创 hdu 1698 Just a Hook 线段树 成段更新

#include #include #include using namespace std; const int N =100005; int sum[N<<2]; int type[N<<2]; void PushUp(int rt){ sum[rt]=sum[rt<<1]+sum[rt<<1|1]; } void PushDown(int rt,int l){ if(type[rt]

2014-03-30 01:06:11 478

原创 hdu 1166 敌兵布阵 线段树 单点更新

#include #include #include using namespace std; const int N =50005; int sum[N<<2]; int a[N]; void build(int l,int r,int rt){ if(l==r){ sum[rt]=a[l]; return; } int mid=(l+r)>>1; build(l,mid,rt<

2014-03-29 23:06:27 435

原创 HDU 4504 威威猫系列故事――篮球梦 母函数&DP

#include #include #include using namespace std; const int N =125; int dp[N]; __int64 a1[N],b1[N]; int main(){ int a,b,t; while(scanf("%d%d%d",&a,&b,&t)!=EOF){ t/=15; int temp1=

2014-03-29 17:42:06 685

原创 HDU 4502 吉哥系列故事――临时工计划 dp

#include #include #include using namespace std; const int N=1010; struct node{ int st,ed; int val; }s[N]; int dp[110]; int cmp(node x,node y){ return x.ed<y.ed; } int main(){ int t; int n,m; sca

2014-03-29 16:41:19 516

原创 hdu 4501 小明系列故事――买年货 dp

#include #include #include using namespace std; const int N=110; struct node{ int price; int score; int val; }s[N]; int dp[N][N][7]; int main(){ int n,v1,v2,k; while(scanf("%d%d%d%d",&n,&v1,&v2,&

2014-03-29 16:33:41 582

原创 hdu 4503 湫湫系列故事——植树节

#include #include #include using namespace std; const int N =1010; int a[N]; int main(){ int t,n; scanf("%d",&t); while(t--){ scanf("%d",&n); for(int i=1;i<=n;i++){ scanf("%d",&a[i]); }

2014-03-29 16:25:41 452

原创 hdu 2473 Junk-Mail Filter 并查集删除

#include #include #include #include using namespace std; const int N=1000005; int set[N]; int a[N]; bool vis[N]; int find(int x){ int r=x; while(r!=set[r]){ r=set[r]; } int temp=x; while(x!=r){

2014-03-27 18:47:06 490

原创 hdu 4472 Count dp

#include #include #include using namespace std; const int N=1010; const int inf=1e9+7; int dp[N]; int main(){ int n; int Case=1; while(scanf("%d",&n)!=EOF){ memset(dp,0,sizeof(dp)); dp[1]=1;

2014-03-25 10:55:58 420

原创 FZU 2156 Climb Stairs dp

#include #include #include using namespace std; const int inf = 1000000007; int dp1[10010]; int dp2[10010]; int dp3[10010]; int main(){ int n,x,y,a,b; while(scanf("%d%d%d%d%d",&n,&x,&y,&a,&b)!=EOF){

2014-03-23 21:08:27 528

原创 zoj 2370 Expanding Rods 二分法

#include #include using namespace std; #define PI 2*asin(1.0) int main() { double len,n,c; while(scanf("%lf%lf%lf",&len,&n,&c)!=EOF) { if(len==-1&&n==-1&&c==-1) break; dou

2014-03-16 20:32:58 578

原创 hdu 4800 Josephina and RPG dp

#include #include #include using namespace std; #define N 10002 #define M 122 double rate[M][M]; double dp[N][M]; int a[N]; int main(){ int n,m; while(scanf("%d",&m)!=EOF){ int r=m*(m-1)*(m-2)/6;

2014-03-16 14:31:34 628

原创 hdu 2819 Swap 二分图匹配

#include #include #include #include using namespace std; #define N 110 vectorg[N]; int linker[N]; bool vis[N]; int a[N]; int b[N]; bool dfs(int u){ for(int i=0;i<g[u].size();i++){ int v=g[u][i];

2014-03-15 01:02:18 505

原创 hdu 2818 Building Block 并查集 路径压缩

#include #include #include using namespace std; #define N 30005 int set[N]; int num[N]; int cnt[N]; int find(int x){ if(set[x]==x) return x; int temp=set[x]; set[x]=find(set[x]);//路径压缩,不进行路径压缩果断的超

2014-03-14 20:20:00 469

原创 ZOJ 3725 Painting Storages DP

#include #include #include using namespace std; #define inf 1000000007 #define N 100005 int a[N]; int b[N]; void getsolve(){ b[0]=1; for(int i=1;i<=N;i++){ b[i]=b[i-1]*2%inf; } return; } int mai

2014-03-12 00:40:53 459

原创 Tyvj 1055 沙子合并 DP

#include #include #include using namespace std; #define inf 10000000 #define N 310 int a[N]; int sum[N]; int dp[N][N]; int main(){ int n; while(scanf("%d",&n)!=EOF){ sum[0]=0; memset(dp,0,sizeof

2014-03-12 00:03:24 651

原创 Tyvj 1045 最大的算式 DP

解法一: #include #include #include using namespace std; #define N 110 #define inf -10000 int a[N]; int dp[N][N][N]; int main(){ int n,m; while(scanf("%d%d",&n,&m)!=EOF){ memset(dp,0,sizeof(dp)); f

2014-03-10 22:49:01 496

原创 Fzu 2148 Moon Game 判断凸四边形 判断线段相交

#include #include #include using namespace std; #define N 35 struct Point{ int x,y; }s[N]; struct Line{ Point a; Point b; }; double CrossProd(Point a,Point b,Point c){ return (b.x-a.x)*(c.y-a.y)

2014-03-05 01:04:28 1022

原创 Uest 1421 Adjacent Bit Counts dp

#include #include #include using namespace std; int dp[110][110][2]; void getsolve(){ memset(dp,0,sizeof(dp)); dp[1][1][1]=0; dp[1][0][1]=1; dp[1][0][0]=1; dp[1][1][0]=0; for(int i=2;i<=100;i++

2014-02-28 22:26:05 510

原创 Tyvj 1023 奶牛的锻炼 dp

#include #include #include using namespace std; #define N 2010 int Length[N]; int RunState[N][505]; int StopState[N][501]; int main(){ int n,m; while(scanf("%d%d",&n,&m)!=EOF){ for(int i=1;i<=n;i+

2014-02-22 21:04:29 646

原创 Tyvj 1008 传球游戏 dp

#include #include #include using namespace std; #define N 35 int dp[N][N]; int main(){ int n,m; while(scanf("%d%d",&n,&m)!=EOF){ memset(dp,0,sizeof(dp)); dp[0][1]=1; for(int i=1;i<=m;i++){

2014-02-20 19:55:56 1003

原创 Tyvj 1007 排座椅 4次快排 VS 两次快排+维护Topk数组 贪心

#include #include #include using namespace std; #define N 1010 int Row[N],Column[N]; int TopkRow[N],TopkColumn[N]; int PosColumn[N],PosRow[N]; int main(){ int n,m,k,l,d; while(scanf("%d%d%d%d%d",&m,

2014-02-20 16:32:02 5450

原创 Tyvj 1034 尼克的任务 DP+邻接表

#include #include #include using namespace std; #define inf 0x7f7f7f7f #define N 10010 struct node{ int v; node *next; }; struct vertexNode{ node *head; }g[N]; struct type{ int st,c

2014-01-19 22:57:19 730

空空如也

空空如也

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

TA关注的人

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