博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Bombing HDU, 4022(QQ糖的消法)
阅读量:4331 次
发布时间:2019-06-06

本文共 2728 字,大约阅读时间需要 9 分钟。

 Bombing

Time Limit: 4000/2000 MS (Java/Others)      
Memory Limit: 65768/65768 K (Java/Others)

Problem Description
It’s a cruel war which killed millions of people and ruined series of cities. In order to stop it, let’s bomb the opponent’s base.
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.
 

Input
Multiple test cases and each test cases starts with two non-negative integer N (N<=100,000) and M (M<=100,000) denoting the number of target bases and the number of scheduled bombers respectively. In 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 10
9, 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.
 

Output
For each test case, output M lines, the ith line contains a single integer denoting the number of bases that were destroyed by the corresponding bomber in the input. Output a blank line after each test case.
 

Sample Input
 
3 2 1 2 1 3 2 3 0 1 1 3 0 0
 

Sample Output
 
2 1
 

题目大意:

给你n个敌人的坐标,再给你m个炸弹和爆炸方向,每一个炸弹能够炸横排或竖排的敌人,问你每一个炸弹能炸死多少个人。

解题思路:

用map里面嵌套multiset , 1000多ms,还是有点长的,老师说要用list ,不知是否要快点。

代码:

#include
#include
#include
#include
#define maxN = 10010;using namespace std;typedef map
> def;multiset
::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

转载于:https://www.cnblogs.com/hrhguanli/p/4501642.html

你可能感兴趣的文章
Windows下安装Redis
查看>>
迷宫实现
查看>>
【字符编码】Java字符编码详细解答及问题探讨
查看>>
学习操作系统导图
查看>>
在线的JSON formate工具
查看>>
winform非常实用的程序退出方法!!!!!(转自博客园)
查看>>
xml解析
查看>>
centos安装vim
查看>>
linux工作调度(计划任务)
查看>>
hdu--1698 Just a Hook(线段树+区间更新+懒惰标记)
查看>>
Python学习笔记-EXCEL操作
查看>>
输出保留12位小数的浮点数
查看>>
LnTbtbKLyv
查看>>
springboot ---> spring ioc 注册流程 源码解析 this.prepareContext 部分
查看>>
Java基础随笔
查看>>
图的存储结构
查看>>
图的遍历
查看>>
最小生成树的基本算法
查看>>
MySQL基础操作
查看>>
cf 1004 D Sonya and Matrix
查看>>