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 ...
随机推荐
- poj3280(区间dp)
题目连接:http://poj.org/problem?id=3280 题意:给定一个长度为m(m<=2000)的小写字母字符串,在给定组成该字符串的n(n<=26)个字符的添加和删除费用 ...
- Android判断应用程序从后台回到前台
MainActivity如下: package cc.testbackgroundtofront; import java.util.List; import android.app.Activity ...
- Objective-C之成魔之路【16-使用文件】
郝萌主倾心贡献,尊重作者的劳动成果.请勿转载. 假设文章对您有所帮助,欢迎给作者捐赠.支持郝萌主,捐赠数额任意.重在心意^_^ 我要捐赠: 点击捐赠 Cocos2d-X源代码下载:点我传送 语言的设计 ...
- Linking Containers Together
Linking Containers Together In the Using Docker section we touched on connecting to a service runnin ...
- 在maven仓库中查找jar
findmaven.net是一个查找Jar和查找Maven的Maven仓库搜索引擎,它能够依据Java开发人员提供的Class名或者Jar名找到包括它的Jar.同一时候提供Jar的Maven仓库链接. ...
- 核心ASP.NET
1.用于Web应用程序的.NET Framework ASP.NET是.NET Framework的一部分,它可以在通过HTTP请求文档是在WEB服务器上动态创建它们,在.Net Framework中 ...
- jdbc初步(转)
1. Jdbc的六个编程步骤 1. 注册一个驱动 注册驱动程序有三种方式: 方式一:Class.forName(“oracle.jdbc.driver.OracleDriver”); JAVA 规范中 ...
- Windows Phone开发(42):缓动动画
原文:Windows Phone开发(42):缓动动画 前面在讨论关键帧动画的时候,我有意把几个带缓动动画的关键帧动画忽略掉,如EasingColorKeyFrame.EasingDoubleKeyF ...
- VS解决BEX错误但不能关闭DEP保存
报道近期计划BEX错误: 问题签名: 问题事件名称: BEX 应用程序名: Auth.exe 应用程序版本号: 0.0.0.0 应用程序时间戳: 546d9e0c 故障模块名称: Auth.exe 故 ...
- Mac maven环境变量配置
近期一直在学习使用Macbook,在这里记录一下全部遇到的问题 问题起源: 1.Macbook 安装了Eclipse,Eclipse装入插件maven & git , 可是在git中clone ...