POJ3067 Japan
Time Limit: 1000MS | Memory Limit: 65536K | |
Total Submissions: 26270 | Accepted: 7132 |
Description
Input
Output
Test case (case number): (number of crossings)
Sample Input
1
3 4 4
1 4
2 3
3 2
3 1
Sample Output
Test case 1: 5
Source
/**/
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
using namespace std;
const int mxn=;
struct edge{
int x,y;
}e[mxn*];
int cmp(edge a,edge b){
if(a.x!=b.x)return a.x<b.x;
return a.y<=b.y;
}
long long t[mxn];
int n,m,k;
int a[mxn];
inline int lowbit(int x){
return x&-x;
}
void add(int p,int v){
while(p<=m){
t[p]+=v;
p+=lowbit(p);
}
return;
}
int sum(int p){
int res=;
while(p){
res+=t[p];
p-=lowbit(p);
}
return res;
}
int main(){
int T;
scanf("%d",&T);
int i,j;
int cas=;
while(T--){
long long ans=;
memset(t,,sizeof t);
scanf("%d%d%d",&n,&m,&k);
for(i=;i<=k;i++) scanf("%d%d",&e[i].x,&e[i].y);
sort(e+,e+k+,cmp);
for(i=;i<=k;i++){
ans+=sum(m)-sum(e[i].y);
add(e[i].y,);
}
printf("Test case %d: %lld\n",++cas,ans);
}
return ;
}
POJ3067 Japan的更多相关文章
- poj3067 Japan(树状数组)
转载请注明出处:http://blog.csdn.net/u012860063 题目链接:id=3067">http://poj.org/problem? id=3067 Descri ...
- poj3067 Japan 树状数组求逆序对
题目链接:http://poj.org/problem?id=3067 题目就是让我们求连线后交点的个数 很容易想到将左端点从小到大排序,如果左端点相同则右端点从小到大排序 那么答案即为逆序对的个数 ...
- POJ3067:Japan(线段树)
Description Japan plans to welcome the ACM ICPC World Finals and a lot of roads must be built for th ...
- POJ 3067 Japan(树状数组)
Japan Time Limit: 10 ...
- Japan
Japan plans to welcome the ACM ICPC World Finals and a lot of roads must be built for the venue. Jap ...
- POJ 3067 Japan
Japan Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 25489 Accepted: 6907 Descriptio ...
- cdoj 383 japan 树状数组
Japan Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://acm.uestc.edu.cn/#/problem/show/383 Descrip ...
- Day 3 @ RSA Conference Asia Pacific & Japan 2016 (morning)
09.00 – 09.45 hrs Tracks Cloud, Mobile, & IoT Security A New Security Paradigm for IoT (Inter ...
- Day 4 @ RSA Conference Asia Pacific & Japan 2016
09.00 – 09.45 hrs Advanced Malware and the Cloud: The New Concept of 'Attack Fan-out' Krishna Naraya ...
随机推荐
- 读取Exchange的用户未读邮件数的几种方法
[http://www.cnblogs.com/nbpowerboy/p/3539422.html] 可以使用ExchangeServiceBinding获取邮件,他相当于outlook, 来获取服务 ...
- C#基于联通短信Sgip协议构建短信网关程序
此软件基于中国联通Sgip协议程序接口,适合在中国联通申请了短信发送端口的公司使用.短信群发已经成为现在软件系统.网络营销等必不可少的应用工具.可应用在短信验证.信息群发.游戏虚拟商品购买.事件提醒. ...
- Linux curl 详解
Linux下载工具Curl也是Linux下不错的命令行下载工具,小巧.高速,唯一的缺点是不支持多线程下载.以下是他的安装和功能. 安装 $ tar zxvf curl-7.14.0.tar.gz $ ...
- 学习笔记(四): Representation:Feature Engineering/Qualities of Good Features/Cleaning Data/Feature Sets
目录 Representation Feature Engineering Mapping Raw Data to Features Mapping numeric values Mapping ca ...
- [LUOGU] P4251 [SCOI2015]小凸玩矩阵
行列看成点,格子看成边,二分一个边权,删去大于它的边,新图上的最大流>k则答案可以更优,小于k则调整左边界. #include<algorithm> #include<iost ...
- Centos7离线部署kubernetes 1.13集群记录
一.说明 本篇主要参考kubernetes中文社区的一篇部署文章(CentOS 使用二进制部署 Kubernetes 1.13集群),并做了更详细的记录以备用. 二.部署环境 1.kubernetes ...
- k8s资源指标API及metrics-server资源监控
简述: 在k8s早期版本中,对资源的监控使用的是heapster的资源监控工具. 但是从 Kubernetes 1.8 开始,Kubernetes 通过 Metrics API 获取资源使用指标,例如 ...
- nginx站点目录及文件URL访问控制
一.根据扩展名限制程序和文件访问 利用nginx配置禁止访问上传资源目录下的PHP.Shell.Perl.Python程序文件. 配置nginx,禁止解析指定目录下的指定程序. location ~ ...
- destoon模块自定义字段的添加并让其支持搜索的方法
今天看了看模块设置里的自定义字段功能的用法,试着加了个新字段glry,设置了值,然后去数据库moduleid的article表看,字段成功加上了. 于是去template下article文件夹的lis ...
- apply(), applymap(), map()
Pandas 中map, applymap and apply的区别 https://blog.csdn.net/u010814042/article/details/76401133/ Panda ...