poj 2491
来源:互联网 发布:淘宝联盟的结算时间 编辑:程序博客网 时间:2024/05/09 08:15
题目:http://poj.org/problem?id=2491
map暴搞。。找到pre[]为空的即为头结点。 map不清除会超时。。map.clear();
下面是AC代码:
#include<iostream>#include<string>#include<map>using namespace std;int main(){ int t,n,ca=1; cin>>t; while(t--){ map<string , string > pre,next; pre.clear(); next.clear(); string s,e,s_pos; cin>>n; for(int i=0;i<n-1;i++){ cin>>s>>e; next[s]=e; pre [e]=s; } while(pre[s]!=""){ s=pre[s]; } cout<<"Scenario #"<<ca++<<":"<<endl; cout<<s<<endl; while(next[s]!=""){ cout<<next[s]<<endl; s=next[s]; } cout<<endl; } return 0;}
- poj 2491
- poj 2491
- poj-2491
- poj-2491-Scavenger Hunt
- poj 2491 map 问题
- POJ
- poj
- POJ
- POJ
- poj
- poj
- POJ
- POJ
- poj
- POJ
- POJ
- POJ
- POJ
- malloc/free与new/delete的相同点和不同点
- 点击隐藏js效果
- hdu 3887
- 关于数据库连接数问题(为什么要关闭数据库连接,可以不关闭吗?)
- ubuntu下的usb转串口的使用
- poj 2491
- cacti 自定义 模板
- 同一时间,网站mysql的连接过多怎么办?
- MultiActionController
- C#数据库插入的两种实现方式
- 求解sizeof的值
- 敏捷开发“松结对编程”系列之八:微软 Tech ed2011 自组织团队与松结对编程讲稿(敏捷开发)
- oracle 字符集的子集与超集对应关系(10.2)
- wireshark过滤语法总结