Artificial simulation ..

#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
#include<queue>
#include<set>
#include<map>
using namespace std;
#define N 10100
#define inf 1000000010
map<int,int>x,y;
struct X{
int x,y;
bool operator<(const X&a)const{
if(a.x==x)return a.y>y;
return a.x>x;
}
X(int a=0,int b=0):x(a),y(b){}
}tmpx;
struct Y{
int x,y;
bool operator<(const Y&a)const{
if(a.y==y)return a.x>x;
return a.y>y;
}
Y(int a=0,int b=0):x(a),y(b){}
}tmpy;
multiset<Y>sety;
multiset<Y>::iterator py, ty;
multiset<X>setx;
multiset<X>::iterator px, tx;
int main(){
int n, m, u, v;
while(scanf("%d %d",&n,&m),n+m){
x.clear();
y.clear();
setx.clear();
sety.clear();
while(n--){
scanf("%d %d",&u,&v);
x[u]++;
y[v]++;
setx.insert(X(u,v));
sety.insert(Y(u,v));
}
while(m--){
scanf("%d %d",&u,&v);
if(u==0){
if(x.find(v)==x.end()){puts("0");continue;}
printf("%d\n",x.find(v)->second);
x.erase(v);
for(px=setx.lower_bound(X(v,-inf));px!=setx.end();)
{
tmpx = *px;
if(tmpx.x!=v)break;
py = sety.lower_bound(Y(tmpx.x,tmpx.y)); sety.erase(py);
y[tmpx.y]--;
tx = px;
px++;
setx.erase(tx);
}
}
else {
if(y.find(v)==y.end()){puts("0");continue;}
printf("%d\n",y.find(v)->second);
y.erase(v);
for(py=sety.lower_bound(Y(-inf,v));py!=sety.end();)
{
tmpy = *py;
if(tmpy.y!=v)break;
px = setx.lower_bound(X(tmpy.x,tmpy.y));
setx.erase(px);
x[tmpy.x]--;
ty = py;
py++;
sety.erase(ty);
}
}
}
puts("");
}
return 0;
}

Copyright notice : This article is the original article of the blogger . Blog , Do not reprint without permission .

HDU 4022 Bombing STL More related articles on simulation questions

  1. HDU 1262 Look for prime pairs Simulation question

    Title Description : Enter an even number , Judge which two prime numbers with the smallest difference can add this even number , Output these two primes . Topic analysis : Simulation question , It's about efficiency , When judging one by one , As long as 2 Judged n/2 That's all right. , And it's best to judge prime numbers by tabulation . ...

  2. HDU 2093 Test ranking Simulation question

    Problem solving report : Title Description : Write a program for a programming exam C++ Real time submission system ranking , The number given to you is the total number of topics , The penalty time for each error submission is minutes , The name of each user , Then enter the user's completion of each question , There are several situations , First of all , There is only one positive input ...

  3. HDU 4022 Bombing(stl,map,multiset,iterater Traverse )

    subject Refer to the     1     2 #define _CRT_SECURE_NO_WARNINGS // It's using STL Medium map and multiset To do the , The code is simple , It's also easier to understand . ...

  4. HDU 4028 The time of a day STL Simulation question

    Violence works wonders .. #include<stdio.h> #include<iostream> #include<algorithm> #include<vecto ...

  5. hdu 4022 Bombing

    Bombing Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 65768/65768 K (Java/Others)Total Sub ...

  6. HDU 2521 Anti prime number Simulation question

    Problem solving report : Water problem , Attach the code directly , I just feel that the author of this question is full of food , The concept of anti prime has nothing to do with this problem . #include<cstdio> int judge1(int k) { ; ;i& ...

  7. HDU 1256 draw 8 Simulation question

    Problem solving report : I think there is one thing that is not clear about the title, that is, the width of the characters on the horizontal line , The title does not say , In fact, the topic requires that the height of the lower circle is not less than that of the upper circle , The width of the horizontal line is equal to the height of the circle below . #i ...

  8. HDU 4022 Bombing (map + multiset)

    The question : stay x,y The coordinate range is 10 ^ -9 ~~ 10 ^ 9 In the coordinate axis of , Yes 10W A little bit ( Notice that some of the points may be in the same coordinates ), Then there is 10W A asked , Process queries in order of input , For each inquiry a,b    a == ...

  9. hdu 4515 The month of the year

    Small Q A series of stories —— The furthest distance in the world Time Limit: 500/200 MS (Java/Others)    Memory Limit: 65535/32768 K (Java/Others) ...

Random recommendation

  1. 【POJ3691】DNA repair(AC automata ,DP)

    The question : In biology class we learned ,DNA There are only A, C, T and G Four pieces . After scientific discovery ,DNA In sequence , It's not a good gene to contain certain fragments , Such as fragments "ATC" It's a bad clip , be "AGATC ...

  2. PHP-- Get response header (Response Header) Method

    Method 1 : $baiduUrl = "http://www.baidu.com/link";   file_get_contents($baiduUrl); $responseInf ...

  3. linux keepalived+LVS Realization mysql Load balancing from the library

    Antecedents feed : Reference link : http://www.osyunwei.com/archives/7464.html ps: The above is the main reference for this operation , Thank you very much for the contribution of the author of this article , The main purpose of my essay is The explanation is in use ...

  4. users

    NAME users - print the user names of users currently logged in to the current host SYNOPSIS users [O ...

  5. Eclipse Common shortcut key windows

    Ctrl+1: Quick correction Ctrl+W: close current file ctrl+O: open outlineCtrl+D: Delete current row Ctrl+L: Position in a line Ctrl+Q: Go to the last modified location Ctrl+/: Comment code Ctrl+H ...

  6. python in if __name__ == &#39;__main__&#39;

    python in __name__ = '__main__' The role of , What on earth ? There is a classic summary of the meaning of this code : “Make a script both importable and execut ...

  7. 《Genesis-3D Open source game engine -- Horizontal version of the fighting game production tutorial 04: Skills input and detection 》

    4. Skills input and detection summary : The user experience of the skills system , It restricts the players' experience of the whole game . The skill magnificence of game characters , The smooth transition of Lianzhao , And a real sense of impact , As the selling point of a game, it attracts the attention of players . Developers are at the beginning of the game , Will be based on ...

  8. LUA Capture mode URL Coding example analysis

    function escape(s) s=string.gsub(s,"([&=+%c])",function(c) return string.format(" ...

  9. linux System daily management review question explanation

    1. How to look at the present Linux The system has several physics CPU And every one of them CPU The number of nuclear ? 2. There are two common commands to view the system load , Which two ? What do these three values mean ? 3. vmstat r, b, si, so, bi, b ...

  10. Android Typical interface design (8) ——ViewPager+PagerSlidingTabStrip Realize dual navigation

    One . Problem description PagerSlidingTabStrip yes android Open source project , Indicator control . Official website address :https://github.com/astuetz/PagerSlidingTabStrip The ...