hdu 4022 Bombing
Bombing
Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 65768/65768 K (Java/Others)
Total Submission(s): 2650 Accepted Submission(s):
990
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.
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 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.
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.
1 2
1 3
2 3
0 1
1 3
0 0
1
#include<iostream>
#include<cstdio>
#include<string>
#include<cstring>
#include<map>
#include<set>
#include <algorithm>
using namespace std; int main(){
int N,M,i,j,x,y;
while(scanf("%d%d",&N,&M)&&(N||M)){
map<int,multiset<int> > row;
map<int,multiset<int> > col;
for(i=;i<N;i++){
scanf("%d%d",&x,&y);
row[x].insert(y);
col[y].insert(x);
}
for(i=;i<M;i++){
scanf("%d%d",&x,&y);
int ans=;
if(x==){
printf("%d\n",row[y].size());
for(multiset<int>::iterator itr=row[y].begin();itr!=row[y].end();itr++){
col[*itr].erase(y);
}
row[y].clear();
}else{
printf("%d\n",col[y].size());
for(multiset<int>::iterator itr=col[y].begin();itr!=col[y].end();itr++){
row[*itr].erase(y);
}
col[y].clear(); } }
puts(""); } return ;
}
hdu 4022 Bombing的更多相关文章
- 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> >对应起来一行或者 ...
- Bombing HDU, 4022(QQ糖的消法)
Bombing From:HDU, 4022 Submit Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 65768/65768 ...
- hdu 4022 STL
题意:给你n个敌人的坐标,再给你m个炸弹和爆炸方向,每个炸弹可以炸横排或竖排的敌人,问你每个炸弹能炸死多少个人. /* HDU 4022 G++ 1296ms */ #include<stdio ...
- hdu 5290 Bombing plan
http://acm.hdu.edu.cn/showproblem.php?pid=5290 题意: 一棵树,每个点有一个权值wi,选择点i即可破坏所有距离点i<=wi的点,问破坏所有点 最少需 ...
- HDU 4022 stl multiset
orz kss太腻害了. 一.set和multiset基础 set和multiset会根据特定的排序准则,自动将元素进行排序.不同的是后者允许元素重复而前者不允许. 需要包含头文件: #include ...
- 2015 Multi-University Training Contest 1 hdu 5290 Bombing plan
Bombing plan Time Limit: 8000/4000 MS (Java/Others) Memory Limit: 262144/262144 K (Java/Others)To ...
随机推荐
- Xeon Phi 《协处理器高性能编程指南》随书代码整理 part 2
▶ 第四章,逐步优化了一个三维卷积计算的过程 ● 基准代码 #include <stdio.h> #include <stdlib.h> #include <string ...
- js day01
一)什么是JavaScript[以下简称JS] JS是 (1)基于对象 JS本身就有一些现成的对象可供程序员使用,例如:Array,Math,String... JS并不排除你可以自已按一定的规则创建 ...
- Failed to start component [StandardEngine[Tomcat].StandardHost[localhost].StandardContext[]]
今天在测试项目代码时,在idea中配置tomcat7插件运行后一直报如下错误: 解决方案:看了网上大多数办法都是修改xml文件配置,感觉并不适用,最后看到比较靠谱解释如下: pom.xml中jar包发 ...
- 【FZSZ2017暑假提高组Day2】圆盘时钟
[问题描述] 作为出题人的小Z相信大家对上图这样的圆盘时钟都不会陌生——在理想圆盘时钟上,秒针每一分钟转一圈,分针每一小时转一圈,时针每12小时转一圈,它们均是匀速转动的,在0点时三条针均指向表盘上的 ...
- python杂记一
1. 输出CSV文件 用python输出csv文件不难,可是MS office excel和WPS 对输出的CSV文件打开规则不一样. WPS可以支持CSV以'\t'为分隔符,打开文件直接写内容 MS ...
- pynlpir 报错 Cannot Save user dictionary 原因与解决方法
在使用pynlpir和用户自定义词典进行分词时,如果报出如下错误: [2017-12-09 18:05:51] Cannot Save user dictionary Cannot write log ...
- hbase--知识点总结2
--用java操作hbase 1.配置jar包环境 创建hbase项目 --> 新建folder文件夹 --> 将hbase相关jar包全部导入到java项目之中 --> add b ...
- JSON转Excel
1.引入js (dist目录下JsonExportExcel.min.js) <script src="https://cuikangjie.github.io/JsonExportE ...
- Windows server 2012 R2 解决“无法完成域加入,原因是试图加入的域的SID与本计算机的SID相同
Windows server 2012 R2 解决“无法完成域加入,原因是试图加入的域的SID与本计算机的SID相同.”使用克隆的系统时,加域是出现如下问题.“无法完成域加入,原因是试图加入的域的SI ...
- JDK、JRE、JVM的区别
JDK: JDK(Java Development Kit)顾名思义它是给开发者提供的开发工具箱,是给程序开发者用的.它除了包括完整的JRE(Java Runtime Environment),Jav ...