HDU - 4022 Bombing (multiset)

稳定性性能系列之五——Native Crash深度分析:工具实战 深入理解Native Crash的机制与分析方法,掌握addr2line、ndk-stack、gdb等核心工具的实战使用,学会从Tombstone文件中快速定位问题根因 阅读详情
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个轰炸机,n个基地的坐标和轰炸机轰炸的行数或列数,算一台轰炸机可以轰炸多少基地(先被轰炸过的基地不会被再炸一次)

#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <cstdio>
#include <functional> //小根堆特有头文件
typedef long long ll;
#define N 1005
using namespace std;
typedef map<int,multiset<int> >line;
map<int,multiset<int> >mx;
map<int,multiset<int> >my;
int bomb(line &x,line &y,int pos) //使用引用缩减代码长度
{
    int ret=x[pos].size();//*得到结果
    multiset<int>::iterator it;  //清空相同的坐标
    for(it=x[pos].begin();it!=x[pos].end();it++)
        y[*it].erase(pos);
    x[pos].clear();
    return ret;
    
}
int main()
{
    int n,m,
    while(scanf("%d%d",&n,&m)==2){
         int tx,ty,c,d;
        if(n==0&&m==0)
            break;
        mx.clear();
        my.clear();
        for(int i=0;i<n;i++)
        {
            scanf("%d%d",&tx,&ty); //将坐标存入容器
            mx[tx].insert(ty);   //tx为关键字 ty为值
            my[ty].insert(tx);   //ty为关键字 tx为值
        }
        for(int i=0;i<m;i++){
            scanf("%d%d",&c,&d);
            int ans;
            if(c==0) ans=bomb(mx,my,d);
            else     ans=bomb(my,mx,d);
            printf("%d\n",ans);
        }
        printf("\n");
    }
}


YOLOv8改进,YOLOv8添加DCNv3可变性卷积,无需编译 DCNv3在DCNv2版本上进行了改进,上一期我们在YOLOv8中添加了DCNv2,这一期我们将添加DCNv3,DCNv3代码详解可以参考链接:代码详解——可变形卷积(DCNv3) 阅读详情

相关推荐

迪文DGUSII串口屏中文显示实战:手把手教你制作16x16点阵字库

本文提供了一份迪文DGUSII串口屏16x16点阵中文字库制作的完整实战指南。从显示原理、字体选择与参数设置,到使用FontLib Make工具生成字库文件,再到部署、调用及存储空间优化,手把手教你解决中文显示难题,确保界面文字既美观又稳定。

weixin_29190573的博客 168

hdu 4022(map一对多)

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4022 STL应用,一开始用multimap写的,然后实现不了,于是就看了别人用map自定义了一个一对多。。。orz。。。 剩下的就简单了。。分别用两个这样的map容器装下 x为键,y为值,和y为键,x为值的两个容器。 然后当C==0就输出当键位d的容器大小,并且去掉另一个容器中出现的点。 同理C...

weixin_33721427的博客 202

Agent框架系列:1-低代码智能体平台深度解析Dify、Coze、n8n

Dify、Coze 和 n8n 是三大主流低代码智能体平台,各有侧重。Dify 适合企业级 AI 应用,具备强大的 RAG 和知识库管理能力,技术栈为 Python + React。Coze 由字节推出,主打零代码和快速原型开发,集成 60+ 插件,极适合非技术用户。n8n 以工作流自动化和系统集成为核心,支持 400+ 外部应用,基于 Node.js + Vue,扩展性极强。选择建议:非技术团队选 Coze,AI 应用选 Dify,复杂自动化与集成选 n8n。可根据实际需求混合使用,最大化平台优势。

3099

HDU4022 bombing [map与multiset]

1.使用map<int,multiset<int>> x_map,y_map储存基地的位置。x_map表示x轴上(x=1,2,3...)存在的基地,y_map同理。3.使用find查找对应的x轴或y轴上是否存在军事基地,如果找到(没有返回最后一个迭代器),使count(摧毁军事基地的数量)等于it内层的大小,删去该map上对应的军事基地,并删去另一个map上对应的军事基地。2.x_map的结构 x_map={ 1->{1,2,3},3->{3}...}。

2403_87149971的博客 572

SAP 人力资源工资配置项3---工资项配置

工资项设置

xiouluoyang的专栏 1万+

利用netmq在相机应用于unity之间传输图像数据

Unity工业相机接入方案解析 本文探讨了在Unity中接入不同品牌工业相机的技术方案。研究发现: Basler相机可直接调用官方DLL(pylonc.net.dll)实现接入 海康和大恒相机因驱动DLL依赖C++组件,无法直接调用 解决方案:通过独立进程(相机应用程序)与Unity进行通信,采用NetMQ实现图像数据传输 技术实现要点: 相机端:使用PublisherSocket发布JPEG图像帧 Unity端:通过SubscriberSocket订阅图像数据 优化:设置高水位线控制缓存帧数,避免数据堆积

weixin_46450859的博客 423

hdu4022

题目大意:给你n个点(二位),坐标范围(<10^9)然后m次询问0 s 表示询问x = s这条线上有多少个点并删除1 s 表示询问y = s这条线上有多少个点并删除import java.io.BufferedInputStream; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStre

老李2009 835

YOLOv8【第一章:基础入门篇·第1节】一文搞定,核心架构深度解析与环境配置!

🏆 本文收录于 《YOLOv8实战:从入门到深度优化》 专栏,该专栏专注于分享我在YOLOv8目标检测模型中的实战经验,涵盖从入门基础到深度优化的全方位解决方案。无论你是计算机视觉的新手,还是具有多年深度学习经验的专家,本专栏都将为你提供高效、可复现的技术方案,助你掌握YOLOv8的核心技术,提升目标检测性能,突破瓶颈,优化模型,并加速项目开发🚀!

**My Coding Family** 2112

Bombing(HDU-4022)

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 circumstanc

JSMSG 501

【即插即用模块】Transformer篇 | TCSVT 2025 | DAFM:双注意力聚合+反向跨模态筛选,特征精准捕捉并融合!

本文提出了一种双模态注意力融合模块(DAFM),用于增强多模态图像融合任务中的特征交互。该模块通过双注意力聚合机制,结合自注意力与跨模态注意力,有效提升特征融合效果。DAFM采用可学习平衡因子动态调整注意力权重,并运用深度卷积降低计算复杂度。实验结果表明,该模块能显著提升多模态图像融合质量,适用于RGB-红外等双模态视觉任务。模块代码实现简洁,可直接集成到现有网络中作为特征融合层使用。

主要更新底层视觉(去噪、超分等)相关的科研内容,形式为【论文精读】+【论文复现】 182

Qt实现思维导图功能1『核心树』

利用Qt的QGraphicsView框架实现思维导图功能 百度网盘体验地址: 链接:https://pan.baidu.com/s/15x9F48agCDOQbsyH3VwVXA 提取码:8svh 注:UI风格参考博主:前行中的小猪,博文地址:https://blog.csdn.net/GoForwardToStep/article/details/124692790?utm_medium=distribute.pc_relevant.none-task-blog-2~default~baidujs_u

浮生流年的博客 6168

HDU 4022

题目:http://acm.hdu.edu.cn/showproblem.php?pid=4022 方法一:很容易想到可以用stl 解决。。但是就是不能构造出来。。因为不知道map的一对多要怎么搞。。(map&lt;int ,multiset&lt;int &gt; &gt;这样可以一对多 取其对应的迭代值要这样 for(multiset&lt;int&gt;::iterator it=a...

fuerbosi 172

可食用野生植物检测实战:基于YOLOv11的智能识别系统全流程指南

本文介绍了一种基于YOLOv11的可食用野生植物智能识别系统。该系统通过深度学习技术,能在0.2秒内精准识别植物是否可食用,准确率高达92%。文章详细阐述了从数据采集、标注到模型训练、验证的全流程,并开发了用户友好的Tkinter交互界面。该系统解决了户外探险和植物研究中植物识别的痛点,具有高精度、实时性和强泛化能力的特点,为户外安全提供了智能化解决方案。

FJN110的博客 167

hdu4022 bombing map+multiset

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, ho...

mayuqing98的博客 258

vb 6.0并口开发操作实例

vb6并口开发,简体中文,试例内有inpout32.dll动态链接库

Devexpress16.2.6破解工具

Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具

hdu 4022 Bombing map+multiset 解题报告

Bombing Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 65768/65768 K (Java/Others) Total Submission(s): 4026    Accepted Submission(s): 1504 Problem Description It’s a cruel war w

小夥的博客 450

LinePhone3.2.7(android端最新版本) sip客户端

SIP客户端For android:LinePhone3.2.7(最新版本),官网地址:http://www.linphone.org/

hdu 4022 Bombing(map,multiset)

题意:n个基地放在2维平面,然后m个炸弹人,每个炸弹人可以炸一行或者一列,输出每个炸弹人炸掉的基地个数。 思路:用map<int,multiset<int> >对应起来一行或者一列。(用set没过,估计数据里有多个基地位于同一个点上) #include<iostream> #include<stdio.h> #include<m...

weixin_30532759的博客 131

文档:亲测可用解决vnc灰屏,黑屏,鼠标大黑叉情况

主要解决vnc-viewer灰屏,黑屏,鼠标大黑叉等现象,详细见文档。

HDU 4022 Bombing (map + multiset)

题意: 在x,y坐标范围为10 ^ -9 ~~ 10 ^ 9的坐标轴之中,有 10W个点(注意有些点可能在同一坐标上),然后有10W个询问,处理询问按照输入顺序处理,对于每个询问a,b    a == 0 代表对 x == b轴处理; a == 1 代表 对y == b轴处理。处理即为把该轴上的点全部清空,输出清空的点的数量。已经清空的点,不计算在接下来的询问中。 思路:map + mu

Paradiser 843

HDU 4022 Bombing(map+multiset)

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, h...

MInNrz的Love&Share 308

HDU 4022 - Bombing (multiset+离散化)

http://acm.hdu.edu.cn/showproblem.php?pid=4022 题意: 给你n个二维坐标点。 按顺序问你m条和坐标轴平行的直线,能去掉多少点。 去掉的点不重复计算。   POINT: 点会重复,所以用multiset。 还是很简单的,不说了。直接看代码吧。   #include &lt;set&gt; #include &lt;map&gt; #...

Mr_Treeeee的博客 290

HDU_4022_Bombing

HDU_5022_Bombing 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

Sothan 507

HDU 4022 Bombing

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

DEC_BIN的博客 522

Bombing HDU, 4022(QQ糖的消法)

题目大意: 给你n个敌人的坐标,再给你m个炸弹和爆炸方向,每个炸弹可以炸横排或竖排的敌人,问你每个炸弹能炸死多少个人。 解题思路: 用map里面嵌套multiset , 1000多ms,还是有点长的,老师说要用list ,不知是否要快点。

Menglei Min 1510

hdoj4022 Bombing (map+multiset && 二分)

题目:http://acm.hdu.edu.cn/showproblem.php?pid=4022 题意:有n个基地 ,m个炸弹,每个基地都有一个坐标(x,y) ,每个炸弹有一个性质(c,d),当c=0时炸弹可以炸掉x=d的一行,当c=1时炸弹可以炸掉y=d的一行。 问每个炸弹炸掉了多少个基地,被炸掉后的基地不重复计数。 #include #include #include #inclu

cowboy90的专栏 715

HDU 4022 Bombing STL 模拟题

手动模拟。。 #include #include #include #include #include #include #include #include using namespace std; #define N 10100 #define inf 1000000010 mapx,y; struct X{ int x,y; bool operator<(const X&a)const{

九野的博客 1741

hdu 4022 Bombing

4022Bombing 题目大意:给你n个点(二位),坐标范围(<10^9)然后m次询问 0 s 表示询问x = s这条线上有多少个点 1 s 表示询问y = s这条线上有多少个点 一个点被算过以后和面的询问就不能再计算了 分析:最容易想到的就是每次询问后把计算过的点标记一下下次询问就不需要再计算了,然后对于维护一下每个横纵线上有多少点。但坐标范围很大怎么办? STL!!!真的...

weixin_33724570的博客 90
上一篇: HDU - 4006 The kth great number (优先队列 小根堆)
下一篇: POJ3250 牛的视野(单调栈)
深海沧澜夜未央
博客等级 码龄10年 763粉丝 552原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值