Bombing HDU, 4022(QQ糖的消法)
Bombing
Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 65768/65768 K (Java/Others)
It seems not to be a hard work in circumstances of street battles, however, you’ll be encountered a much more difficult instance: recounting exploits of the military. In the bombing action, the commander will dispatch a group of bombers with weapons having
the huge destructive power to destroy all the targets in a line. Thanks to the outstanding work of our spy, the positions of all opponents’ bases had been detected and marked on the map, consequently, the bombing plan will be sent to you.
Specifically, the map is expressed as a 2D-plane with some positions of enemy’s bases marked on. The bombers are dispatched orderly and each of them will bomb a vertical or horizontal line on the map. Then your commanded wants you to report that how many bases
will be destroyed by each bomber. Notice that a ruined base will not be taken into account when calculating the exploits of later bombers.
the following N line, there is a pair of integers x and y separated by single space indicating the coordinate of position of each opponent’s base. The following M lines describe the bombers, each of them contains two integers c and d where c is 0 or 1 and
d is an integer with absolute value no more than 109, if c = 0, then this bomber will bomb the line x = d, otherwise y = d. The input will end when N = M = 0 and the number of test cases is no more than 50.
case.
3 2
1 2
1 3
2 3
0 1
1 3
0 0
2
1
题目大意:
给你n个敌人的坐标,再给你m个炸弹和爆炸方向,每一个炸弹能够炸横排或竖排的敌人,问你每一个炸弹能炸死多少个人。
解题思路:
用map里面嵌套multiset , 1000多ms,还是有点长的,老师说要用list ,不知是否要快点。
代码:
#include<iostream>
#include<set>
#include<map>
#include<cstdio>
#define maxN = 10010;
using namespace std; typedef map<int,multiset<int> > def;
multiset<int>::iterator it;
int n,m;
def hang,lie; void pop(def &a,def &b,int c){
printf("%d\n",a[c].size());
for(it=a[c].begin();it!=a[c].end();it++)
b[*it].erase(c);//直接释放那个值的位置
a[c].clear(); } void input(){
int x,y;
for(int i=0;i<n;i++){
scanf("%d%d",&x,&y);
lie[x].insert(y);
hang[y].insert(x);
}
} void solve(){
int a,b;
for(int i=0;i<m;i++){
scanf("%d%d",&a,&b);
if(a==0) pop(lie,hang,b);
else pop(hang,lie,b);
}
printf("\n");
} int main(){
while(~scanf("%d%d",&n,&m)&&(n||m)){
input();
solve();
}
return 0;
}
Bombing HDU, 4022(QQ糖的消法)的更多相关文章
- hdu 4022 STL
题意:给你n个敌人的坐标,再给你m个炸弹和爆炸方向,每个炸弹可以炸横排或竖排的敌人,问你每个炸弹能炸死多少个人. /* HDU 4022 G++ 1296ms */ #include<stdio ...
- hdu 4022 Bombing
Bombing Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 65768/65768 K (Java/Others)Total Sub ...
- HDU 4022 Bombing(stl,map,multiset,iterater遍历)
题目 参考了 1 2 #define _CRT_SECURE_NO_WARNINGS //用的是STL中的map 和 multiset 来做的,代码写起来比较简洁,也比较好容易理解. ...
- HDU 4022 Bombing (map + multiset)
题意: 在x,y坐标范围为10 ^ -9 ~~ 10 ^ 9的坐标轴之中,有 10W个点(注意有些点可能在同一坐标上),然后有10W个询问,处理询问按照输入顺序处理,对于每个询问a,b a == ...
- HDU 4022 Bombing STL 模拟题
人工模拟.. #include<stdio.h> #include<iostream> #include<algorithm> #include<vector ...
- hdu 4022 Bombing(map,multiset)
题意:n个基地放在2维平面,然后m个炸弹人,每个炸弹人可以炸一行或者一列,输出每个炸弹人炸掉的基地个数. 思路:用map<int,multiset<int> >对应起来一行或者 ...
- HDU 4022 stl multiset
orz kss太腻害了. 一.set和multiset基础 set和multiset会根据特定的排序准则,自动将元素进行排序.不同的是后者允许元素重复而前者不允许. 需要包含头文件: #include ...
- ListView获取网络数据并展示优化练习
权限: <uses-permission android:name="android.permission.INTERNET"></uses-permission ...
- asp.net Mvc 使用NPOI导出Excel文件
1.新建MVC项目,新建控制器.视图 添加控制器: 添加视图(将使用布局页前面的复选框里的勾勾去掉) 2.在Models里新建一个类 public class Shop { /// <summa ...
随机推荐
- 【IOS实例小计】今日开贴,记录我的ios学习生涯,留下点滴,留下快乐,成荫后人。
今天开贴来记录自己的ios学习过程,本人目前小白一个,由于对ios感兴趣,所以开始学习,原职java程序,呵呵,勿喷. 本次的[ios实例小计]主要参考一文http://blog.sina.com.c ...
- SE 2014年4月13日
要求自治系统之间建立BGP邻居关系,AS 100 中由于配置疏忽R5上忘记启用BGP,从而导致了黑洞问题出现.从而需要网络工程师们就现状问题进行分析,并且使用相应技术进行完善,使得AS 400 和AS ...
- Android HAL
- hdu 4454 Stealing a Cake(三分法)
给定一个起始点,一个矩形,一个圆,三者互不相交.求从起始点->圆->矩形的最短距离. 自己画一画就知道距离和会是凹函数,不过不是一个凹函数.按与水平向量夹角为圆心角求圆上某点坐标,[0, ...
- C++ Primer 学习笔记_62_重载操作符与转换 --调用操作符和函数对象
重载操作符与转换 --调用操作符和函数对象 引言: 能够为类类型的对象重载函数调用操作符:一般为表示操作的类重载调用操作符! struct absInt { int operator() (int v ...
- The Building Blocks-Enterprise Applications Part 2- Information Management and Business Analytics
1. Business Analytic Applications Data Analytics Also referred to as 'Business Analytics' or 'Busine ...
- IOS应用程序生命周期详解
第一. IOS应用程序的五种状态: 1. Not running:应用还没有启动,或者应用正在运行但是途中被系统停止. 2. Inactive:当前应用正在前台运行,但是并不接收事件(当前或许正在执行 ...
- cocos2d-x截图功能clippingnode它也可用于——白费
许多其他精彩分享:http://blog.csdn.net/u010229677 3.1版本号: 在Director数: bool Director::saveScreenshot(const std ...
- poj1260
给定n类等级的珍珠 每类的珍珠都有需求的个数ai,和价格pi 为了防止游客只买1颗珍珠,所以购买ai个珍珠时,要加上10个的价格 即(ai+10)*pi 有时,购买高等级的珍珠代替低等级的珍珠时,可能 ...
- ImageButton消除使用setImageDrawable造成的边框问题。
使用ImageButton的时候,如果使用setBackgroundDrawable设置图片,会对可点击范围有影响,使用setImageDrawable方法设置图片,图片小的话,可以会有,这种有白色边 ...