poj 3067(树状数组)
来源:互联网 发布:windows一键重装 编辑:程序博客网 时间:2024/05/16 14:56
点击打开链接
题意:
日本东岸有n个城市,西岸有m个城市,每个城市,从北到南编号为1,2,..,两岸的城市之间有k条高速路,求这k条高速路有多少焦点。。。
跟stars是一个类型的,先对第1个数从大到小,对第二个数从大到小。。
这样ans用int64,还有k最大为1000*1000
#include"stdio.h"#include"string.h"#include"algorithm"using namespace std;#define N 1000011int C[N];struct node{int x,y;}A[N];int cmp(node a,node b){if(a.x!=b.x)return a.x>b.x;return a.y>b.y;}int bit(int x){return x&(-x);}int sum(int x){int ans=0;while(x){ans+=C[x];x-=bit(x);}return ans;}void add(int x,int a){while(x<N){C[x]+=a;x+=bit(x);}}int main(){int k,t;int n,m;int i,T;__int64 ans;t=1;scanf("%d",&T);while(T--){scanf("%d%d%d",&n,&m,&k);for(i=0;i<k;i++)scanf("%d%d",&A[i].x,&A[i].y);sort(A,A+k,cmp);//for(i=0;i<k;i++)//printf("%d%d\n",A[i].x,A[i].y);memset(C,0,sizeof(C));ans=0;for(i=0;i<k;i++){ans+=sum(A[i].y-1);add(A[i].y,1); }printf("Test case %d: %I64d\n",t++,ans);}return 0;}
- poj 3067(树状数组)
- poj 3067 树状数组
- POJ 3067 树状数组
- poj 3067 树状数组
- poj 3067(树状数组)
- poj 3067 树状数组
- POJ 3067【树状数组】
- POJ-3067-树状数组
- poj - 3067 - Japan(树状数组)
- POJ 3067 Japan (树状数组)
- poj 3067(树状数组逆序数)
- POJ 3067 Japan (树状数组)
- POJ 3067 Japan (树状数组)
- POJ 3067 Japan(树状数组 )
- POJ 3067 Japan(树状数组)
- poj-3067-Japan(树状数组)
- POJ 3067 Japan (树状数组)
- POJ 3067 Japan(树状数组)
- mybatis+springMVC整合出现Mapped Statements collection does not contain value for ***
- Oracle的操作系统身份认证
- 求割点详解 以poj1523为例
- CI8.8--八皇后问题
- Eclipse 在开发中使用到的快捷键很实用
- poj 3067(树状数组)
- MFC中CenterWindow()函数的模拟,对话框居中显示
- POJ 1655 Balancing Act【树的重心】
- 有多少程序员具有写技术博客的习惯
- 【iPod转换精灵V10.2 官方最新版】强大的视频转换功能
- C#泛型类之LIST<T>
- 网卡驱动想要成功入住Ubuntu中要这样操作【老牌系统】
- N2CMS 实践之路 Part.1 前期准备
- Spring的事物管理