/* * POJ_2003.cpp * * Created on: 2013年11月5日 * Author: Administrator */ #include #include #include #include #include using namespace std; struct Tman{ string name; Tman* f; list s; Tman(){ f = NULL; } }; map hash; Tman* root; void print(long dep,Tman* now){ if(now == NULL){ return ; } long i; for(i = 1 ; i name::iterator it = now->s.begin(); it != now->s.end() ; ++it){ print(dep+1,*it); } } void hire(string n1,string n2){ Tman* f = hash[n1]; Tman* s = new Tman(); s->name = n2; s->f = f; f->s.push_back(s); hash[n2] = s; } void fire(string n1){ Tman* s = hash[n1]; Tman* f = s->f; hash.erase(n1); while(s->s.size() != 0){ s->name = s->s.front()->name; hash[s->name] = s; s = s->s.front(); } s->f->s.remove(s); delete s; } void solve(){ string s1,s2; long i; cin >> s1; root = new Tman(); hash[s1] = root; root->name = s1; while(cin >> s1){ if(s1 == "print"){ print(0,root); for(i = 1 ; i > s2; fire(s2); }else{ cin >> s2; cin >> s2; hire(s1,s2); } } } int main(){ solve(); return 0; }
服务器托管,北京服务器托管,服务器租用 http://www.hhisp.net 机房租用,北京机房租用,IDC机房托管, http://www.e1idc.net
hackdl
咨询热线/微信 13051898268
本公司主要经营服务器托管,服务器租用,IDC机房托管租用,数据中心租赁,电信联通移动BGP多线带宽租用租赁,GPU服务器托管,超算机房租用,机房高电机柜租用,带宽传输,互联网接入,多种云计算增值服务,可一站式提供AI人工智能,金融证券银行,游戏视频电商等各种解决方案,欢迎咨询!