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.
3 2 1 2 1 3 2 3 0 1 1 3 0 0
2 1
#include<bits/stdc++.h>
using namespace std;
#define ma map<int,multiset<int> >
#define se multiset<int>
ma a,b;
void my_solve(se &r1,ma &r2,int d)
{
int cnt=0;
for(set<int>::iterator it=r1.begin();it!=r1.end();it++)
{
r2[*it].erase(d);
cnt++;
}
r1.clear();
cout<<cnt<<endl;
}
int main()
{
int n,m;
while(~scanf("%d%d",&n,&m)&&(n!=0||m!=0))
{
int x,y;
for(int i=1;i<=n;i++)
{
scanf("%d%d",&x,&y);
a[x].insert(y);
b[y].insert(x);
}
for(int i=1;i<=m;i++)
{
int c,d,cnt=0;
scanf("%d%d",&c,&d);
if(c==0)
my_solve(a[d],b,d);
else
my_solve(b[d],a,d);
}
printf("\n");
a.clear();
b.clear();
}
return 0;
}
762



被折叠的 条评论
为什么被折叠?



