I have been doing this for a whole day !!!!!!!!!!
Also, it's been a whole day !!!!!!!!!
It turned out that the card was too late ....
936ms .....
It's actually eggache .....
At the beginning, I didn't know what m was doing. As a result, wa ....
Later, because too many map queries and inserts, such as t_map ["ABC"], took too long.
Because t_map ["ABC"] = 1 must first query and modify the value when "ABC" exists.
However, if "ABC" does not exist, executing BB = t_map ["ABC"] queries and inserting a new "ABC ".
You know, the red/black tree takes a long time to insert...
Therefore, when using map in the future, try to use insert and find for insertion and query. In this way, the time can be minimized ....
# Include <stdlib. h> <br/> # include <stdio. h> <br/> # include <string. h> <br/> # include <string> <br/> # include <iostream> <br/> # include <map> <br/> # include <vector> <br /> using namespace STD; <br/> typedef Map <string, int> string2map; </P> <p> int main () <br/>{< br/> int n, m; <br/> int I, j; <br/> int K; <br/> char name [25], like [25], hate [25], go [25]; <br/> Map <string, string2map> t_map; <br/> Map <string, string 2map >:: iterator it_t; <br/> Map <string, bool> t_now; <br/> Map <string, bool >:: iterator it_n; <br/> string2map:: iterator it_f; <br/> string2map s2m; <br/> string t_add [101], t_remove [101]; <br/> int p_add, p_remove; <br/> int H, L; <br/> int geted; <br/> while (scanf ("% d", & N, & M )! = EOF) <br/>{< br/> t_map.clear (); <br/> t_no1_clear (); <br/> for (I = 0; I <N; I ++) <br/>{< br/> scanf ("% s", name); <br/> scanf ("% d", & K ); <br/> t_map [name] = s2m; <br/> it_t = t_map.find (name); <br/> for (j = 0; j <K; j ++) <br/>{< br/> scanf ("% s", like); <br/> it_t-> second. insert (string2map: value_type (like, 1); <br/> // it_t-> second [like] = 1; <br/>}< br/> scanf ("% d", & K); <br/> for (j = 0; j <K; j ++) <br/>{< br/> scanf ("% s", hate); <br/> it_t-> second. insert (string2map: value_type (hate, 2); <br/> // it_t-> second [hate] = 1 <1; <br/>}< br/> scanf ("% d", & K); <br/> for (j = 0; j <K; j ++) <br/>{< br/> scanf ("% s", go); <br/> t_now [go] = true; <br/>}< br/> for (I = 0; I <m; I ++) <br/> {<br/> p_add = 0; <br/> p_remove = 0; <br/> it_t = t_map.begin (); <br/> for (; it_t! = T_map.end (); it_t ++) <br/>{< br/> it_n = t_now.begin (); <br/> L = H = 0; <br/> for (; it_n! = T_no1_end (); it_n ++) <br/>{< br/> it_f = it_t-> second. find (it_n-> first); <br/> If (it_f! = It_t-> second. end () <br/>{< br/> geted = it_f-> second; <br/> If (geted & 1) l ++; <br/> If (geted & 1 <1) h ++; <br/> If (L> 0 & H> 0) break; <br/>}< br/> If (H = 0 & L> 0) <br/> t_add [p_add ++] = it_t-> first; <br/> If (h> 0 & l = 0) <br/> t_remove [p_remove ++] = it_t-> first; <br/>}< br/> If (p_remove = 0 & p_add = 0) <br/> break; <br/> for (j = 0; j <p_remove; j ++) <br/> t_nocycleras E (t_remove [J]); <br/> for (j = 0; j <p_add; j ++) <br/> t_no1_insert (make_pair (t_add [J], true); <br/>}< br/> If (t_no1_empty () <br/>{< br/> printf ("NONE/N "); <br/> continue; <br/>}< br/> it_n = t_now.begin (); <br/> cout <it_n-> first; <br/> it_n ++; <br/> for (; it_n! = T_now.end (); it_n ++) <br/> cout <"" <it_n-> first; <br/> cout <Endl; <br/>}< br/> return 0; <br/>}