标签:map
#include <cstdio> #include <cmath> #include <iostream> #include <algorithm> #include <cstdlib> #include <cstring> #include <map> #include <string> using namespace std; int main() { #ifndef ONLINE_JUDGE freopen("D:/1.txt","r",stdin); freopen("D:/2.txt","w",stdout); #endif int casen; cin>>casen; int tt=0; for(int caset=1;caset<=casen;caset++) { map<string,string>path; map<string,int>point; map<string,int>::iterator it; int len; cin>>len; for(int i=0;i<len-1;i++) { string s1,s2; cin>>s1>>s2; path[s1]=s2; point[s1]=0; point[s2]=1; } for(it=point.begin();it!=point.end();it++) { if(it->second==0) { break; } } string start=it->first; //cout<<start<<endl; cout<<"Scenario #"<<caset<<":\n"; cout<<start<<'\n'; for(int i=0;i<len-1;i++) { cout<<path[start]<<'\n'; start=path[start]; } cout<<'\n'; } return 0; }
POJ2491 Scavenger Hunt【裸map】,布布扣,bubuko.com
标签:map
原文地址:http://blog.csdn.net/u011775691/article/details/28050539