雕刻时光

just do it……nothing impossible
  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

2011年7月15日

摘要: 题意:统计左下方的星星数容易出现TLE的情况因为0<=X,Y<=32000x=0时,因为0&(-0)=0,所以会在树状数组里出现死循环解决办法是每个x++;由于y是升序的,故不用考虑,就统计X即可View Code #include<cstdio>#include<iostream>using namespace std;int n;int tree[50009];int add[50009];int a[50009];int lowbit(int x){ return x&(-x);}void updata(int x,int c){ in 阅读全文

posted @ 2011-07-15 17:01 huhuuu 阅读(170) 评论(0) 推荐(0) 编辑

摘要: 由于点范围比较大所以用离散化一下点如2 1 3n=3然后,在树状数组里放依次放入updata(2,1),统计sum(n)-sum(1),updata(1,1),统计sum(n)-sum(3)View Code 阅读全文

posted @ 2011-07-15 15:40 huhuuu 阅读(128) 评论(0) 推荐(0) 编辑

摘要: 输入n然后n个数字输出需要换几次View Code #include<cstdio>#include<iostream>#include<algorithm>using namespace std;struct data{ int val; int no; int N;}a[500009];int hash[500009];int cmp(data a,data b){ return a.val<b.val;}int cmp1(data a,data b){ return a.no<b.no;}int main(){ int n; while(s 阅读全文

posted @ 2011-07-15 13:59 huhuuu 阅读(241) 评论(0) 推荐(0) 编辑

摘要: 求最小排序交换次数贪心做View Code #include<stdio.h>#include<algorithm>#include<iostream>using namespace std;int b[1009],a[1009];int min(int a,int b){ if(a>b)return b; else return a;}int max(int a,int b){ if(a>b)return a; else return b;}int main(){ int n; int add[6]; while(scanf("%d& 阅读全文

posted @ 2011-07-15 11:17 huhuuu 阅读(343) 评论(0) 推荐(0) 编辑

摘要: 离散化,对区间离散化31 101 36 10染色3会变成1 41 23 4染色2所以要区间*22 82 46 8染色3错的,却AC的代码View Code对的代码,虽然被烂数据判错View Code 阅读全文

posted @ 2011-07-15 09:53 huhuuu 阅读(143) 评论(0) 推荐(0) 编辑