View code
1 # Include < Stdio. h >
2 # Include < String . H >
3 # Define Maxcompute 32200
4 Int C [Max], level [Max];
5 Int N;
6 Int Get_val ()
7 {
8 Int RET ( 0 );
9 Char C;
10 While (C = Getchar ()) = ' ' | C = ' \ N ' | C = ' \ R ' );
11 RET = C - ' 0 ' ;
12 While (C = Getchar ()) ! = ' ' && C ! = ' \ N ' && C ! = ' \ R ' )
13 RET = RET * 10 + C - ' 0 ' ;
14 Return RET;
15 }
16 Int Lowbit ( Int X)
17 {
18 Return X & ( - X );
19 }
20 Void Update ( Int X, Int Num)
21 {
22 While (X <= Max)
23 {
24 C [x] + = Num;
25 X + = Lowbit (X );
26 }
27 }
28 Int Get_sum ( Int X)
29 {
30 Int S = 0 ;
31 While (X > 0 )
32 {
33 S + = C [x];
34 X -= Lowbit (X );
35 }
36 Return S;
37 }
38 Int Main ()
39 {
40 Int I, X, Y;
41 While ( ~ Scanf ( " % D " , & N ))
42 {
43 Memset (C, 0 , Sizeof (C ));
44 Memset (level, 0 , Sizeof (Level ));
45 For (I = 1 ; I <= N; I ++ )
46 {
47 X = Get_val (); y = Get_val ();
48 Level [get_sum (x + 1 )] ++ ;
49 Update (x + 1 , 1 );
50 }
51 For (I = 0 ; I < N; I ++ )
52 Printf ( " % D \ n " , Level [I]);
53 }
54 Return 0 ;
55 }