上一页 1 2 3 4 5 6 7 8 9 ··· 42 下一页
貌似和以前做过的某道题一模一样,离线查询在这里http://www.cnblogs.com/wuyiqi/archive/2012/02/13/2349290.htmlView Code #include<cstdio>#include<cstring>#include<map>#include<algorithm>using namespace std;const int maxn = 50010;__int64 c[maxn];struct node{ int l,r,id;}p[200010];map<int,int> Hash Read More
posted @ 2012-05-17 17:06 Because Of You Views(227) Comments(0) Diggs(0) Edit
此题有一个关键的地方决定了可以使用树状数组来搞:所有询问的区间不相互包含,但可能交叉这样就可以从左往右边添加边删除用树状数组来做了如果存在包含关系,就不能用树状数组搞了,原因的话看看poj 2104的样例数据就明白了View Code #include<cstdio>#include<cstring>#include<algorithm>using namespace std;const int maxn = 100010;struct node{ int key,id; bool operator < (const node & cm)con Read More
posted @ 2012-05-17 16:59 Because Of You Views(787) Comments(0) Diggs(0) Edit
A 给你一个环,环上的每条边都有一个方向,按某个方向(顺时针或逆时针)走一遍,把与行走的方向相反的边反向,并加上相应的费用,判断走哪个方向的费用比较少直接dfs搞即可View Code #include<cstdio>#include<cstring>#include<vector>#include<algorithm>using namespace std;int out[110];vector<int> edge[110];int flag[110][110];int mm[110][110];int vis[110];vecto Read More
posted @ 2012-05-17 05:51 Because Of You Views(381) Comments(0) Diggs(0) Edit
要解决的核心问题是:求1~x(在base进制下)的区间内各数位上的数字之和恰好为m的数的个数对于每一个询问,先预处理一个DPdp[i][j]表示在base进制下 长度为i且 数位之和为j的数的个数然后在calc()中一位一位统计过去就好了View Code #include<cstdio>#include<cstring>#include<algorithm>using namespace std;typedef __int64 lld;lld dp[32][331];//dp[i][j]:长度为i,数位和为j时的数的个数void init(int lim, Read More
posted @ 2012-05-15 13:44 Because Of You Views(338) Comments(0) Diggs(0) Edit
1-n的排列题目给出m对 a b,表示a位置放b问你满足其中至少一对关系的总排列数反过来求,先求出一对关系都不满足的排列数,在用总的排列数减去它具体做法是对于每个位置,枚举那些不能放的数放在这个位置,不断地去更新状态数组#include<cstdio>#include<cstring>#include<algorithm>using namespace std;typedef __int64 lld;lld fac[20];lld dp[1<<19];int re[20][20];void init(){ fac[0]=1; for(int i= Read More
posted @ 2012-05-13 10:54 Because Of You Views(307) Comments(0) Diggs(0) Edit
http://codeforces.com/problemset/problem/12/D线段树View Code #include<cstdio>#include<cstring>#include<algorithm>using namespace std;const int inf = ~0u>>2;const int N = 500010;#define lson l,m,rt<<1#define rson m+1,r,rt<<1|1int Max[N<<2];struct node{ int x,y,z Read More
posted @ 2012-05-12 20:05 Because Of You Views(417) Comments(0) Diggs(0) Edit
和poj 的hotel差不多,多了一些细节处理的过程给一辆汽车安排空位的时候还需要和前后的车都保持一定的车距,如果前面没车或者后面没车,则可以停在边界上典型的线段树区间合并View Code #include<cstdio>#include<cstring>#include<vector>#include<map>#include<algorithm>using namespace std;#define lson l,m,rt<<1#define rson m+1,r,rt<<1|1const int max Read More
posted @ 2012-05-01 11:15 Because Of You Views(521) Comments(0) Diggs(0) Edit
BRMQ+LCA+边双连通View Code #include<string.h>#include<stdio.h>#include<vector>#include<math.h>using namespace std;const int M =100100;const double inf = 1e20;inline int min(int a,int b){return a<b?a:b;}int tdfn,tot;int dp[20][2*M],vis[M];int B[2*M],LOG[2*M],used[M],F[2*M],pos[ Read More
posted @ 2012-04-29 16:34 Because Of You Views(414) Comments(0) Diggs(0) Edit
View Code /*给你n个物品,每个物品有一定的体积,给你一个总体积一定的背包,问你用这个背包去装这些物品的时候,背包中的物品共有几种不同的组合一种组合是合法的:剩下的背包容量必须《剩下的物品的体积的最小值*/#include<cstdio>#include<cstring>#include<algorithm>using namespace std;int dp[1010];int v[50];int max(int a,int b){ return a>b?a:b;}int main(){ int t,i,j,k,V,D,ca=1; scan Read More
posted @ 2012-04-29 14:00 Because Of You Views(352) Comments(0) Diggs(0) Edit
题意:有一个售货员,n个顾客,卖给 i 这个顾客的价格是pi,i 顾客来买东西的时刻为 ti如果有w的时间段没人来买东西,售货员就会睡着,下一个顾客来时会叫醒她,但是不买东西售货员会卖给第i个来(相对顺序)的顾客1 + ((i- 1) mod 3)的数量的面包 即 1 2 3 中的一个问使得平均的销售额最大的最小w以及此时的平均销售额是多少( 总的销售额/顾客的个数)做法:我觉得关键是要抓住题目的特点,深挖下去,售货员每隔w时间会睡着,那就意味着,1:如果有个顾客和上一个顾客间的时间间隔超过了w,这个顾客就不糊买东西,而与上一个顾客来的时间间隔小于等于w的顾客肯定能买到面包所以我们只需枚举每个 Read More
posted @ 2012-04-28 10:13 Because Of You Views(1031) Comments(0) Diggs(0) Edit
上一页 1 2 3 4 5 6 7 8 9 ··· 42 下一页