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 ...
随机推荐
- Luogu P1666 前缀单词
校内资格赛题目,差点高一就要\(\tt{AFO}\)了 30分思路 对30%的数据,满足$1≤n≤10 $ 所以我们可以子集枚举,实际得分40pts #include<iostream> ...
- Diff Two Arrays-freecodecamp算法题目
Diff Two Arrays(比较两个数组) 1.要求 比较两个数组,然后返回一个新数组 该数组的元素为两个给定数组中所有独有的数组元素.换言之,返回两个数组的差异. 2.思路 定义一个新数组变量, ...
- NOIP模拟赛 密室逃脱
密室逃脱(maze.*) 即使czhou没有派出最强篮球阵容,机房篮球队还是暴虐了校篮球队.为了不打击校篮球队信心,czhou决定改变训练后的活动.近来,江大掌门的徒弟徒孙们纷纷事业有成,回到母校为机 ...
- [提供可行性脚本] RHEL 7/CentOS 7/Fedora28 重命名网卡名称
实验说明: 在许多自动化任务中,脚本往往是通过读取配置文件来获取信息的,红帽系的系统自升级之后(CentOS7/RHEL7),网卡命名采用“一致性网络设备接口”的命名方法,导致不同设备的不同网卡名称各 ...
- day3-python 登录
import datetime # 1. f = open('users') result = f.read() f.close() user_list = result.split() # user ...
- redis+PHP消息队列实现及应用
学习视频: http://www.imooc.com/learn/852 学习笔记: https://blog.csdn.net/qq_33862644/article/details/7938564 ...
- 图解Disruptor框架(一):初识Ringbuffer
图解Disruptor框架(一):初识Ringbuffer 概述 1. 什么是Disruptor?为什么是Disruptor? Disruptor是一个性能十分强悍的无锁高并发框架.在JUC并发包中, ...
- GoF23种设计模式之行为型模式之模板方法
概述 定义一个操作中的算法的骨架,而将一些步骤延迟到子类中. TemplateMethod使得子类可以不改变一个算法的结构即可重定义该算法的某些特定步骤. 适用性 1.一次性实现一个算法的不变的部分, ...
- LeetCode(117) Populating Next Right Pointers in Each Node II
题目 Follow up for problem "Populating Next Right Pointers in Each Node". What if the given ...
- private virtual in c++
source from http://blog.csdn.net/steedhorse/article/details/333664 // Test.cpp #include <iostream ...