随笔分类 -  树状树组

摘要:StarsTime Limit:1000MSMemory Limit:65536KTotal Submissions:29602Accepted:12924DescriptionAstronomers often examine star maps where stars are represented by points on a plane and each star has Cartesian coordinates. Let the level of a star be an amount of the stars that are not higher and not to the 阅读全文
posted @ 2014-03-07 16:46 ~~Snail~~ 阅读(149) 评论(0) 推荐(0)
摘要:A Simple Problem with IntegersTime Limit:5000MSMemory Limit:131072KTotal Submissions:53810Accepted:16150Case Time Limit:2000MSDescriptionYou haveNintegers,A1,A2, ... ,AN. You need to deal with two kinds of operations. One type of operation is to add some given number to each number in a given interv 阅读全文
posted @ 2014-03-06 10:30 ~~Snail~~ 阅读(134) 评论(0) 推荐(0)
摘要:1 #include 2 #define MAX 100000 3 4 //数组c为树状数组,MAX为数状数组大小 5 int c[MAX]; 6 7 //lowbit函数 8 int lowbit(int x) 9 {10 return x&(-x);11 }12 13 //树状数组求和函数,求c[1]+c[2]+…+c[x]14 //注意如果题目中可能出现x=0的情况,这里会出现死循环而TLE,改进方法是将原数据全部+115 int sum(int x)16 {17 int ret=0;18 19 while(x>0)20 {21 re... 阅读全文
posted @ 2014-02-06 21:31 ~~Snail~~ 阅读(176) 评论(0) 推荐(0)
摘要:N(3N20000)ping pong players live along a west-east street(consider the street as a line segment). Each player has a unique skill rank. To improve their skill rank, they often compete with each other. If two players want to compete, they must choose a referee among other ping pong players and hold th 阅读全文
posted @ 2014-02-06 21:20 ~~Snail~~ 阅读(240) 评论(0) 推荐(0)