Japan
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
- #include"iostream"
- #include"algorithm"
- #include"cstring"
- #include"cstdio"
- using namespace std;
- structxy
- {
- int x,y;
- }a[1000010];
- int c[1005];
- //long long int max;
- int cmp(const xy&a,const xy&b)
- {
- if(a.x!=b.x)
- return a.x<b.x;
- else
- return a.y<b.y;
- }
- int lowbit(int x)
- {
- return x&(-x);
- }
- void updata(int x,int d,int max)
- {
- while(x<=max)
- {
- c[x]+=d;
- x+=lowbit(x);
- }
- }
- long long int getsum(int x)
- {
- long long int res=0;
- while(x>0)
- {
- res+=c[x];
- x-=lowbit(x);
- }
- return res;
- }
- int main()
- {
- int i,t,p=0;
- scanf("%d",&t);
- while(t--)
- {
- int n,m,k,max;
- memset(c,0,sizeof(c));
- max=0;
- scanf("%d%d%d",&n,&m,&k);
- for(i=0;i<k;i++)
- {
- scanf("%d%d",&a[i].x,&a[i].y);
- if(a[i].y>max)
- max=a[i].y;
- }
- sort(a,a+k,cmp);
- long long int sum=0;
- updata(a[0].y,1,max);
- for(i=1;i<k;i++)
- {
- sum+=getsum(max)-getsum(a[i].y);
- updata(a[i].y,1,max);
- }
- printf("Test case %d: %lld\n",++p,sum);
- }
- return 0;
- }
Japan的更多相关文章
- POJ 3067 Japan(树状数组)
Japan Time Limit: 10 ...
- 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 ...
- POJ 3067 - Japan - [归并排序/树状数组(BIT)求逆序对]
Time Limit: 1000MS Memory Limit: 65536K Description Japan plans to welcome the ACM ICPC World Finals ...
- poj3067 Japan(树状数组)
转载请注明出处:http://blog.csdn.net/u012860063 题目链接:id=3067">http://poj.org/problem? id=3067 Descri ...
- Japan POJ - 3067 转化思维 转化为求逆序对
Japan plans to welcome the ACM ICPC World Finals and a lot of roads must be built for the venue. Jap ...
- cdojR - Japan
地址:http://acm.uestc.edu.cn/#/contest/show/95 题目: R - Japan Time Limit: 3000/1000MS (Java/Others) ...
随机推荐
- TBluetoothLE
delphi 蓝牙技术 D:\Users\Public\Documents\Embarcadero\Studio\17.0\Samples\Object Pascal\Multi-Device Sam ...
- Hadoop应用开发实战案例 第2周
比如,封面,是一网页,可以看出用户在此网页上,鼠标呈现F形状. 海量Web日志分析 用Hadoop提取KPI统计指标 更详细原文博客:http://blog.fens.me/hadoop-mapred ...
- MySQL [Warning] Can’t create test file xxx lower-test(转)
add by zhj:修改的数据库的datadir,然后数据库就无法启动了,错误如下 2014-12-11 16:22:57 26309 [Warning] Can't create test fil ...
- 门户级UGC系统的技术进化路线——新浪新闻评论系统的架构演进和经验总结(转)
add by zhj:先收藏了 摘要:评论系统是所有门户网站的核心标准服务组件之一.本文作者曾负责新浪网评论系统多年,这套系统不仅服务于门户新闻业务,还包括调查.投票等产品,经历了从单机到多机再到集群 ...
- 【MySQL】源码编译安装和配置MySql 5.5.32(单实例)
[需求描述] 在CentOS环境中,通过编译源码的方式,安装并且配置“单实例”的MySQL5.5.32数据库. MySQL的安装目录为:/application/mysql-5.5.32 MySQL数 ...
- ASA与PIX的区别
很多年来,Cisco PIX一直都是Cisco确定的防火墙.但是在2005年5月,Cisco推出了一个新的产品——适应性安全产品(ASA,Adaptive Security Appliance).不过 ...
- centos 安装redis php
$ wget http://download.redis.io/releases/redis-3.0.7.tar.gz $ tar xzf redis-3.0.7.tar.gz $ cd redis- ...
- asp获取勾选checkbox的值
Dim str_select str_select = CStr(request.Form("c_name")) c_name是checkbox的name
- OBD Experts OBD II Software OBD II Protocol Stack
http://www.obdexperts.co.uk/stack.html OBD II Software OBD Experts can provide you with ready to use ...
- Winform学习手册(目录)
一.基础: WINFORM学习笔记——创建Winform项目 WINFORM学习手册——TextBox.Lable.Button WINFORM学习笔记——窗体生命周期 WINFORM学习手册——对话 ...