【STL】hdu 4022 Bombing

泰克示波器TDS210改装便携示波器 泰克示波器TDS210改装编写示波器 阅读详情

Bombing

Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 65768/65768 K (Java/Others)
Total Submission(s): 4267    Accepted Submission(s): 1606


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

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
 
///AC代码
#include<stdio.h>
#include<iostream>
#include<set>
#include<map>
#include<algorithm>
using namespace std;

// 建立一个 map,从 int 到 一个 multiset 容器的映射
typedef map<int, multiset<int> > line; // 两个>间一定要加个空格
map<int, multiset<int> >mx; //定义x坐标对应的map
map<int, multiset<int> >my; //定义y坐标对应的map

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);    //multiset 去除一个元素
    }
    x[pos].clear();//清空multiset
    return ret;
}
int main()
{
    int n, m;
    int c, d;
    int tx, ty;
    while (scanf("%d%d", &n, &m) != EOF)
    {
        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);
            my[ty].insert(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");
    }
    return 0;
}


[cryoEM] cryoSPARC简介 cryoSPARC系统结构概述 cryoSPARC是一个后端和前端高性能计算软件系统,为单颗粒冷冻电镜提供数据处理和图像分析能力,以及丰富的基于浏览器的用户截面和命令行工具。 Master-worker模式 系统基于主用户模式。 主进程(web应用,核心应用程序和MongoDB数据库)一起在主节点上运行。主节点需要相对轻量级的资源(2+ CPU< 16GB+ RAM)。 工作程序进程可以在具有GPU的任何可用节点上生成,负责所有实际计算和数据处理,并由主节点调度。注意:同一节点可以同时充当主节点和辅 阅读详情

相关推荐

STM32驱动HC-SR04超声波模块:两种精准测距方案详解

本文详解STM32驱动HC-SR04超声波模块的两种精准测距方案:定时器中断计数法和外部中断边沿检测法。涵盖硬件连接、代码实现与优化技巧,帮助开发者根据精度和复杂度需求选择合适方案,提升超声波测距在嵌入式项目中的稳定性和准确性。

g5h6i的博客 691

HDU 4022 Bombing c++解法

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

qq_41773202的博客 549

智能座舱架构与芯片- (9) 音频篇 上

从A2B收发器衍生出来的简化产品具备各种级别的功能,例如端点从节点(不支持TDM)、简化型主节点(支持较短的电缆和更少的从节点数量),以及简化型端点从节点(支持较短电缆和更少的PDM输入)。例如,AVB中的talker和listener是不同的设备,它们的参考时钟源可能并不相同。传统的车载收音机通过天线接收无线电信号,然后由调谐模块(Tuner)进行信号调谐,信道过滤,信道均衡,多路改善,信号解调等,转为数字信号后再交给DSP进行立体声解码,噪声抑制,弱信号处理,最后从车载音响系统进行播放。

joanna_xiao的博客 4925

HDU - 4022 Bombing (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,

深海沧澜的博客 292

无人驾驶汽车系统入门(三十二)——FEC算法:点云快速欧几里得聚类实战解析

本文深入解析了FEC算法在无人驾驶点云聚类中的高效应用,通过逐点处理策略和体素栅格预分割技术,实现了比传统欧几里得聚类快百倍的速度。文章详细介绍了算法原理、Python实现及参数调优指南,并对比了FEC与传统算法的性能差异,为无人驾驶系统开发提供了实用解决方案。

weixin_29065015的博客 490

XGBoost调参新姿势:Bayesian优化实战指南(附完整代码)

本文详细介绍了如何使用Bayesian优化方法高效调优XGBoost模型参数。通过解析Bayesian优化核心原理和XGBoost关键参数,提供完整的实战代码示例,帮助读者掌握这一智能调参技术,显著提升模型性能。文章特别适合机器学习工程师和数据科学家阅读。

weixin_42536058的博客 369

Bombing HDU, 4022(QQ糖的消法)

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

Menglei Min 1510

STM32电机PID速度控制

2.3 STM32电机PID速度控制 之前的文章,完成了直流减速电机的PWM控制、电机测速。本篇文章,将实现电机的速度闭环控制。 在公众号:小白学移动机器人,发送:速度PID,即可获得本篇文章的STM32工程文件以及相关资料。 2.3.1 解决的问题 解决带编码器直流电机的速度闭环问题。 2.3.2 PID理论 将偏差的比例、积分、微分,通过线性组合构成控制量,用控制量对被控对象进行控制,这样的控制器称为PID控制器。在连续空间中,我们通常探讨模拟PID的控制原理,如图所示: 我们这里用电机速度控制为例,

「小白学移动机器人」一个专注分享移动机器人相关知识的公众号! 6万+

HDU 4022 Bombing(基本算法-水题)

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 har...

weixin_30644369的博客 281

使用Qt编译Qt WebEngine

这就是使用Qt编译Qt WebEngine模块的基本步骤。通过按照上述步骤,您应该能够成功编译和使用Qt WebEngine来嵌入Web内容到您的Qt应用程序中。Qt WebEngine是Qt框架的一个模块,它提供了一个现代的Web浏览器引擎,可以在Qt应用程序中嵌入Web内容。首先,需要获取Qt的源代码。如果尚未安装,可以从Qt官方网站下载并安装Qt。完成Qt的安装后,您可以构建并运行Qt WebEngine示例来验证编译是否成功。这将把编译好的Qt库文件和头文件安装到之前指定的安装目录中。

DevForge的博客 3023

华为OD机试真题 新系统 2026-04-26 Python&JS 实现【最大化游戏试玩资格分发】

新研发了一台游戏设备可以面向用户接受试玩。现有 n 个试玩申请,每个试玩有开始时间和结束时间。作为协调员,为了能让更多人体验到游戏,你需要对试玩申请进行选择,使得:

MISAYAONE的博客 298

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

Python之ae-toolbox包语法、参数和实际应用案例

ae-toolbox(全称 after-effects-toolbox)是 Python 生态中专门用于 Adobe After Effects(AE)自动化操作 的工具包,基于 AE 的 ExtendScript(JSX)桥接技术,实现 Python 与 AE 的跨语言通信。

王国平的博客 1179

HDU 4022 Bombing STL/二分

用stl的set和map #include #include #include #include #include #include #include #include using namespace std; typedef map > def; void pop(def &a,def &b,int k) { printf("%d\n",a[k].size()); for(multise

1292765944的专栏 1053

汉书HE8,好用的汇编代码编写工具

汉书HE8,好用的汇编代码编写工具早期编写汇编代码所用功能强大

Outlook Express 6 (OE6) for Win7/Win8/Win10

英文版 Outlook Express6.0, 兼容Win7/Win10/WinXP,解压就可用。

HDU 4022 Bombing (STL)

题意: 给出包含N个点的点集和M次操作 对于每个操作 w z w=1时 删除 坐标y=z的点,并输出个数 w=0时 删除 坐标x=z的点,并输出个数 思路: AVL树问题,STL实现即可 代码: #include using namespace std; const int INF=0x3f3f3f3f; typedef struct Node{ int k1;

DT2131 403

Statistics and Machine Learning Toolbox

Statistics and Machine Learning Toolbox(带书签),MATLAB统计学习工具

hdu 4022 Bombing(STL)

BombingTime Limit: 4000/2000 MS (Java/Others)    Memory Limit: 65768/65768 K (Java/Others)Total Submission(s): 4834    Accepted Submission(s): 1813Problem DescriptionIt’s a cruel war which killed mill...

Timeclimber 515

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

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

HDU 4022 Bombing (STL应用)

Bombing Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 65768/65768 K (Java/Others)Total Submission(s): 1377    Accepted Submission(s): 533 Problem Description It’s a cruel war which killed...

weixin_34126557的博客 127

2011年上海网络赛·STL·HDU 4022 Bombing

题目大意:给定一张图中的基地坐标,再给定m个炸弹:'0'  x: 炸掉坐标为x的基地'1' y :炸掉坐标为y的基地解题思路:map存储基地,开两个分别存对应x和y的基地;查询直接输出size,不要忘记删掉炸过的基地AC代码:#include &lt;map&gt; #include &lt;set&gt; #include &lt;stack&gt; #include &lt;cmath&gt;...

吾之奉先的博客 185

HDU 4022Bombing 2011网络赛(二分 或 STL)

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

布生气 1871

hdu4022_Bombing(STL_map)

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

no2015214099的博客 280

hdu4022 Bombing stl(map+set)

The 36th ACM/ICPC Asia Regional Shanghai Site —— Online Contest 题意:轰炸机轰炸基地,一颗炸弹炸一排或一行,按顺序输出每个轰炸机轰炸基地的个数。 map+set 除了代码短,时空复杂度都高,囧~要用其他方法做

749

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

Bombing HDU - 4022

Bombing HDU - 4022 题意:给出n个目标,m个炸弹,每个炸弹可以炸一行或者一列,问每一个炸弹摧毁了多少目标。 可以用STL做,也可以二分做。 这是kuangbin的代码~ 用STL很简洁,但是慢 1 /* 2 HDU 4022 3 G++ 1296ms 4 5 6 */ 7 8 9 #include<st...

weixin_30292843的博客 167

HDU 4022 Bombing

题目大意,给如N个点(x,y),再给出M个炸弹,每次可以炸横的一整排或者竖直方向一整排, 输出每个炸弹炸毁多少个点 网上发现一段超精湛的STL做法.学习一下 用map,将横竖坐标分别映射到一个multiset,然后做相应的维护即可 每次输出即是输出整个set的大小 #include #include #include #include #include #include #inclu

Criyson的专栏 1515

hdu 4022 Bombing

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

weixin_33724570的博客 90
上一篇: 【STL】hdu 1004 Let the Balloon Rise
下一篇: 【STL】poj 1256 Anagram
斌同学斌同學
博客等级 码龄10年 4粉丝 257原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值