Bombing(map+multset)
来源:互联网 发布:js中如何给文本框赋值 编辑:程序博客网 时间:2024/06/06 06:57
Bombing
Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 65768/65768 K (Java/Others)Total Submission(s): 4329 Accepted Submission(s): 1622
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.
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 21 21 32 30 11 30 0
Sample Output
21
Source
The 36th ACM/ICPC Asia Regional Shanghai Site —— Online Contest
题意:给你n个敌人的坐标,再给你m个炸弹和爆炸方向,每个炸弹可以炸横排或竖排的敌人,问你每个炸弹能炸死多少个人。
/*分别用两个map容器装下 x为键,y为值,和y为键,x为值。 然后当C==0就输出当键位d的容器大小,并且去掉另一个容器中出现的点。*/#include<stdio.h>#include<map>#include<algorithm>#include<iostream>#include<string.h>#include<set>using namespace std;typedef map<int,multiset<int> >def; void pop1(def &a,def &b,int k){ printf("%d\n",a[k].size()); for(multiset<int>::iterator it=a[k].begin();it!=a[k].end();it++) b[*(it)].erase(k); a[k].clear(); }int main(){int n,m;while(scanf("%d%d",&n,&m)!=EOF){if(n==0&&m==0)break;def h,l;for(int i=0;i<n;i++){int a,b;cin>>a>>b;h[a].insert(b);l[b].insert(a);}for(int j=0;j<m;j++){int x,y;scanf("%d%d",&x,&y);if(x==0)pop1(h,l,y);else pop1(l,h,y);}printf("\n");}}
阅读全文
0 0
- Bombing(map+multset)
- hdu4022 Bombing stl(map+set)
- HDU 4022 Bombing (map + multiset)
- HDU Bombing (STL multiset+map)
- map hdu 4022 Bombing
- hdoj4022 Bombing (map+multiset && 二分)
- HDU 4022 Bombing set和map的结合
- (二分+数据结构+暴力)hdu 4022 Bombing
- HDU 4022 Bombing(基本算法-水题)
- hdu 5290 Bombing plan(树形dp)
- HDU 5290 Bombing plan(树形DP)
- C++ Set和multSet
- C++ STL set/multset
- BOMbing The System
- hdu 4022 Bombing
- hdoj 4022Bombing( STL )
- HDU 4022 Bombing
- HDU 4022 Bombing
- 【杭电1233 -- 还是畅通工程】 (最小生成树)
- 包装类
- vs2013+qt5.6添加qcustomplot报无法解析的外部符号
- UDP服务器
- C++中字符串你的基本常识
- Bombing(map+multset)
- nginx配置详解--动静分离
- 日常学习2017.08.05
- UDP客户端
- CodeVS 2370 LCA 解题报告
- 并查集
- C语言常见错误
- Android----动画
- java学习20天总结7-31到8-4