1 2 3 1 2 3 41 1 2 2 3 3 41 2 3 4
1#include <cstdio>2#include <iostream>3#include <cstring>4#include <list>5#include <map>6 using namespacestd;7 8map<int,list<int> >m;9 Ten intn,x,y; One Charop[10000]; A intMain () { -scanf"%d",&n); - while(n--){ thescanf"%s", op); - if(strcmp (OP,"New")==0){ -scanf"%d",&x); -M.insert (map<int,list<int> >::value_type (x,list<int>())); + } - if(strcmp (OP,"Add")==0){ +scanf"%d%d",&x,&y); A m[x].push_back (y); at } - if(strcmp (OP,"Merge")==0){ -scanf"%d%d",&x,&y); - M[x].merge (M[y]); - //m[y].clear (); - } in if(strcmp (OP,"Unique")==0){ -scanf"%d",&x); to M[x].sort (); + M[x].unique (); - } the if(strcmp (OP," out")==0){ *scanf"%d",&x); $ M[x].sort ();Panax Notoginsenglist<int>:: iterator it; - for(It=m[x].begin (); It!=m[x].end (); it++){ theprintf"%d",*it); + } Aprintf"\ n"); the } + } -}
Since there is a list of the STL, the long experience is really ~ ~ ~