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 ...
随机推荐
- Android_多媒体_SoundPool声音池使用
1.SoundPool概述 SoundPool就相当于一个简单的集合,可以将apk中的资源或者系统中的文件加载至内存中,使用了MediaPlayer服务区解码音频文件,用SoundPool可以播一些短 ...
- 京东商城招聘scala 高级开发工程师 T3级别
岗位级别:T3 岗位职责: 1.参与自动调价.匹配系统的设计和实现 岗位要求: 1. 一年以上scala开发经验2.良好的函数式编程能力3. JAVA基础扎实4.熟悉大数据处理,有hadoop/hba ...
- Nagios+pnp4nagios+rrdtool 安装配置nagios(一)
基于的软件版本 Apache-2.0.63 php-5.3.2 nagios-3.2.3 nagios-plugins-1.4.15 rrdtool-1.4.5 nrpe-2.12 pnp4na ...
- 关于LIST.Select().ToList()慢的问题
var sendlist = emailList.Select(email => new MailMessage { MailServer = SMTPServer, UserName = Se ...
- as 的妙用
个人理解:as跟is is 相当于判断里的“==” 是与否 if(e.OriginalSource is Button) as 一般用来转换另一种object e.OriginalSource as ...
- java.lang.NullPointerException错误分析
java.lang.NullPointerException是什么错误 你使用了空的指针.在java中虽然号称抛弃了C++中不安全的指针,但其实他所有的东西你都可以理解为指针.这种情况一般发生在你使用 ...
- MYSQL中取当前年份的第一天和当前周,月,季度的第一天/最后一天
mysql 获取当年第一天的年月日格式:SELECT DATE_SUB(CURDATE(),INTERVAL dayofyear(now())-1 DAY); MySQL里获取当前week.month ...
- What the difference between rebuild index and re-organize index?
avg_fragmentation_in_percent value Corrective statement > 5% and < = 30% ALTER INDEX REORGANIZ ...
- Android开发之文件下载,状态时显示下载进度,点击自动安装
在进行软件升级时,需要进行文件下载,在这里实现自定义的文件下载,并在状态栏显示下载进度,下载完成后,点击触发安装. 效果如图: 用于下载文件和显示现在进度的线程类如下: [java] view pl ...
- PB数据库相关
---------------------------------------------------------------- 数据库画板: 一张表定义了主键或者唯一索引,则能够在Results视窗 ...