题目大意:给你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.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.io.StreamTokenizer;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.NavigableSet;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.Scanner;
import java.util.Set;
import java.util.SortedSet;
import java.util.Stack;
import java.util.StringTokenizer;
import java.util.TreeSet;
import javax.swing.text.NavigationFilter;
public class Main {
public static void main(String[] args) throws IOException{
StreamTokenizer cin = new StreamTokenizer(new BufferedInputStream(System.in));
InputReader in = new InputReader(System.in) ;
PrintWriter out = new PrintWriter(System.out) ;
int n , m ;
while(true){
n = in.nextInt() ;
m = in.nextInt() ;
if(n == 0 && m == 0) break ;
new Task().solve(n , m , in, out) ; // out.flush() ;
out.println();
}
out.flush() ;
}
}
class Task{
public void solve(int n , int m , InputReader in , PrintWriter out) throws IOException{
HashMap<Integer , NavigableSet<E>> sx = new HashMap<Integer , NavigableSet<E>>() ;
HashMap<Integer , NavigableSet<E>> sy = new HashMap<Integer , NavigableSet<E>>() ;
for(int i = 1 ; i <= n ; i++){
int x = in.nextInt() ;
int y = in.nextInt() ;
if(sx.get(x) == null) sx.put(x, new TreeSet<E>()) ;
sx.get(x).add(new E(y, i)) ;
if(sy.get(y) == null) sy.put(y, new TreeSet<E>()) ;
sy.get(y).add(new E(x, i)) ;
}
while(m-- > 0){
int k = in.nextInt() ;
int d = in.nextInt() ;
if(k == 0){
NavigableSet<E> xt = sx.get(d) ;
if(xt == null){
out.println(0) ;
continue ;
}
out.println(xt.size());
for(E e : xt){
int y = e.value ;
NavigableSet<E>dely = sy.get(y) ;
if(dely == null) continue ;
E dy ;
while((dy = dely.higher(new E(d , -1))) != null && dy.value == d){
dely.remove(dy) ;
}
}
xt.clear();
}
else{
NavigableSet<E> yt = sy.get(d) ;
if(yt == null){
out.println(0) ;
continue ;
}
out.println(yt.size());
for(E e : yt){
int x = e.value ;
NavigableSet<E>delx = sx.get(x) ;
if(delx == null) continue ;
E dx ;
while((dx = delx.higher(new E(d , -1))) != null && dx.value == d){
delx.remove(dx) ;
}
}
yt.clear();
}
}
}
}
class E implements Comparable<E>{
int value ;
int id ;
public int compareTo(E o){
if(value != o.value)
return Integer.compare(value, o.value) ;
else return Integer.compare(id, o.id) ;
}
E(int value , int id){
this.value = value ;
this.id = id ;
}
}
class InputReader{
public BufferedReader reader;
public StringTokenizer tokenizer;
public InputReader(InputStream stream){
reader = new BufferedReader(new InputStreamReader(stream), 32768) ;
tokenizer = null ;
}
public String next(){
while(tokenizer == null || ! tokenizer.hasMoreTokens()){
try{
tokenizer = new StringTokenizer(reader.readLine());
}catch (IOException e) {
throw new RuntimeException(e);
}
}
return tokenizer.nextToken();
}
public int nextInt() {
return Integer.parseInt(next());
}
public long nextLong() {
return Long.parseLong(next());
}
}