STL bare question, offline AC, bzoj unlimited re ing ......
1 # include <cstdio> 2 # include <cctype> 3 # include <iostream> 4 # include <string> 5 # include <EXT/pb_ds/assoc_container.hpp> 6 # include <EXT/ pb_ds/tree_policy.hpp> 7 using namespace STD; 8 using namespace _ gnu_cxx; 9 Using namespace _ gnu_pbds; 10 int res, num; char C, CH [20]; 11 inline int g () 12 {13 res = 0; C = '*'; 14 While (C <'0' | C> '9') C = getchar (); 15 while (C> = '0' & C <= '9') {res = res * 10 + (c-'0'); C = getchar ();} 16 Re Turn res; 17} 18 inline void P (int x) 19 {20 num = 0; If (! X) {putchar ('0'); puts (""); return;} 21 While (x> 0) CH [++ num] = x % 10, x/= 10; 22 while (Num) putchar (CH [num --] + 48); 23 puts (""); 24} 25 int N, V, en; 26 string s; 27 struct point28 {string X; int y, z; 29 point (const string & A, const Int & B, const Int & C) {x =; y = B; Z = C;} 30 point () {}}; 31 bool operator <(const point & A, const point & B) {return. y! = B. Y? A. Y <B. y:. z> B. z;} 32 tree <point, null_type, less <point>, rb_tree_tag, struct> T; // on bzoj, change null_type to null_mapped_type33 typedef tree <point, null_type, less <point>, rb_tree_tag, tree_order_statistics_node_update >:: iterator ITER; 34 Map <string, int> Ma, Ma2; 35 inline bool is_name (const string & X) 36 {37 int Len = x. length (); 38 for (INT I = 0; I <Len; I ++) if (! Isalpha (X [I]) return false; 39 return true; 40} 41 inline int to_num (const string & X) 42 {43 int res = 0, base = 1, len = x. length (); 44 for (INT I = len-1; I> = 0; I --) 45 {46 res + = (X [I]-'0') * base; 47 base * = 10; 48} 49 return res; 50} 51 int main () 52 {53 n = g (); 54 for (INT I = 1; I <= N; I ++) 55 {56 CIN> S; 57 if (s [0] = '+') 58 {59 s. erase (0, 1); 60 V = g (); 61 If (MA. find (s )! = Ma. end () T. erase (T. find (point (s, ma [s], Ma2 [s]); 62 ma [s] = V; 63 t. insert (point (s, V, ++ en); 64 Ma2 [s] = en; 65} 66 else67 {68 s. erase (0, 1); 69 If (is_name (s) P (t. size ()-t. order_of_key (point (s, ma [s], Ma2 [s]); 70 else71 {72 V = to_num (s); 73 int I = 1; ITER it = T. find_by_order (T. size ()-V); 74 for (; it --, I ++) 75 {76 printf ("% s", (* it ). x. c_str (); 77 If (IT = T. begin () | I = 10) 78 {79 puts (""); 80 break; 81} 82 putchar (''); 83} 84} 85} 86} 87 return 0; 88}
[Pb_ds] bzoj1056 [haoi2008] ranking system/bzoj1862 [zjoi2006] Gamez game ranking system