摘要: 1 #include 2 #include 3 #include 4 using namespace std; 5 const int maxn=15000+5; 6 const int maxd=32000+5; 7 int c[maxd]; 8 int ans[maxn]; 9 int lowbit(int x)10 {11 return x&-x;12 }13 int sum(int x)14 {15 int ret=0;16 while(x>0)17 {18 ret+=c[x];19 x-=lowbit(x);20 ... 阅读全文
posted @ 2013-08-16 19:22 sooflow 阅读(136) 评论(0) 推荐(0) 编辑
摘要: 1 #include 2 #include 3 #include 4 using namespace std; 5 const int maxn=100000+5; 6 struct edge 7 { 8 int v; 9 edge *next; 10 }; 11 edge *g[maxn]; 12 edge mall[2*maxn]; 13 edge *tmp; 14 int c[maxn]; 15 int s[maxn]; 16 int e[maxn]; 17 int vis[maxn]; 18 int cnt; 19 int n; 20 int top... 阅读全文
posted @ 2013-08-16 19:21 sooflow 阅读(146) 评论(0) 推荐(0) 编辑
摘要: 1 #include 2 #include 3 #include 4 using namespace std; 5 const int maxn=1000010+5; 6 int c[maxn]; 7 int n,m,k; 8 struct pos 9 {10 int e,w;11 bool operator a.e;14 return w>a.w;15 }16 }p[maxn];17 int lowbit(int x)18 {19 return x&-x;20 }21 int sum(int x)22 {23 int ret=0;24 ... 阅读全文
posted @ 2013-08-16 19:20 sooflow 阅读(176) 评论(0) 推荐(0) 编辑
摘要: 1 #include 2 #include 3 const int maxn=1024+5; 4 int s[maxn][maxn]; 5 int n; 6 int lowbit(int x) 7 { 8 return x&-x; 9 }10 long long sum(int x,int y)11 {12 long long ret=0;13 for(int i=x;i>0;i-=lowbit(i))14 for(int j=y;j>0;j-=lowbit(j))15 ret+=s[i][j];16 return ret;1... 阅读全文
posted @ 2013-08-16 19:19 sooflow 阅读(126) 评论(0) 推荐(0) 编辑
摘要: 1 #include 2 #include 3 const int maxn=1000+5; 4 int n,m; 5 int s[maxn][maxn]; 6 int lowbit(int x) 7 { 8 return x&-x; 9 }10 int sum(int x,int y)11 {12 int ret=0;13 for(int i=x;i>0;i-=lowbit(i))14 for(int j=y;j>0;j-=lowbit(j))15 ret+=s[i][j];16 return ret;17 }18 voi... 阅读全文
posted @ 2013-08-16 19:15 sooflow 阅读(169) 评论(0) 推荐(0) 编辑
摘要: 1 #include 2 #include 3 #include 4 using namespace std; 5 const int maxn=20000+5; 6 int dis[maxn]; 7 int num[maxn]; 8 int n; 9 struct COW10 {11 int vol,x;12 bool operator 0)25 {26 ret+=c[x];27 x-=lowbit(x);28 }29 return ret;30 }31 void add(int *c,int x,int inc,in... 阅读全文
posted @ 2013-08-16 19:13 sooflow 阅读(170) 评论(0) 推荐(0) 编辑
摘要: 数据量较大 卡了好几次超时 看了别人的报告 说是可以把电话号码转成整数,大概就是这么做的。 1 #include 2 #include 3 #include 4 using namespace std; 5 const int maxn=200000; 6 char s[500]; 7 char key[26]={'2','2','2','3','3','3','4','4','4','5','5','5' 阅读全文
posted @ 2013-08-05 20:52 sooflow 阅读(158) 评论(0) 推荐(0) 编辑
摘要: 训练指南上面的题目,树状数组,给出一个序列,从左到右表示每个人的值,问存在有多少对{i,j,k}满足Xi 2 #include 3 const int maxval=100000+5; 4 const int maxn=20000; 5 int val[maxn]; 6 int c[maxn]; 7 int b[maxn]; 8 int flag[maxval]; 9 int n;10 int lowbit(int x)11 {12 return x&(-x);13 }14 int sum(int x)15 {16 int ret=0;17 while(x>0)18 ... 阅读全文
posted @ 2013-07-29 23:21 sooflow 阅读(146) 评论(0) 推荐(0) 编辑
摘要: #include#include#includeusing namespace std;int s[65];int vis[65];int n;int sum;bool DFS(int cur,int index,int num,int single){ if(num==sum/single-1) return true; for(int i=index;isingle) continue; if(cur+s[i]==single) { vis[i]=1; if(DFS(0,0,num+1,single)) return true; v... 阅读全文
posted @ 2013-05-14 09:31 sooflow 阅读(114) 评论(0) 推荐(0) 编辑