POJ 2491
#include<iostream>
#include<stdio.h>
#include<string>
#define MAXN 400
using namespace std;
struct node
{
string s1;
string s2;
};
node a[400];
int main()
{
//freopen("acm.acm","r",stdin);
int test;
int num;
int i;
int j;
int k;
int r;
cin>>test;
for(k = 0; k < test; ++ k)
{
cin>>num;
for(i = 0; i < num-1; ++ i)
{
cin>>a[i].s1;
cin>>a[i].s2;
}
for(i = 0; i < num-1; ++ i)
{
for(j = 0; j < num-1; ++ j)
{
if(a[i].s1 == a[j].s2)
{
break;
}
}
if(j == num-1)
{
cout<<"Scenario #"<<k+1<<":"<<endl;
cout<<a[i].s1<<endl;
cout<<a[i].s2<<endl;
for(j = 0; j < num-2; ++ j)
{
for(r = 0; r < num-1; ++ r)
{
if(a[i].s2 == a[r].s1)
{
cout<<a[r].s2<<endl;
a[i].s2 = a[r].s2;
break;
}
}
}
break;
}
}
cout<<endl;
}
}
POJ 2491的更多相关文章
- POJ 2491 Scavenger Hunt map
Scavenger Hunt Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 2848 Accepted: 1553 De ...
- POJ 3370. Halloween treats 抽屉原理 / 鸽巢原理
Halloween treats Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 7644 Accepted: 2798 ...
- POJ 2356. Find a multiple 抽屉原理 / 鸽巢原理
Find a multiple Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 7192 Accepted: 3138 ...
- POJ 2965. The Pilots Brothers' refrigerator 枚举or爆搜or分治
The Pilots Brothers' refrigerator Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 22286 ...
- POJ 1753. Flip Game 枚举or爆搜+位压缩,或者高斯消元法
Flip Game Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 37427 Accepted: 16288 Descr ...
- POJ 3254. Corn Fields 状态压缩DP (入门级)
Corn Fields Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 9806 Accepted: 5185 Descr ...
- POJ 2739. Sum of Consecutive Prime Numbers
Sum of Consecutive Prime Numbers Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 20050 ...
- POJ 2255. Tree Recovery
Tree Recovery Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 11939 Accepted: 7493 De ...
- POJ 2752 Seek the Name, Seek the Fame [kmp]
Seek the Name, Seek the Fame Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 17898 Ac ...
随机推荐
- TortoiseGit使用笔记
不喜欢敲命令行,或者用惯TortoiseSVN的也可以使用TortoiseGit 1. TortoiseGit安装 安装很简单,默认安装就可以.需要安装以下几个软件: l Git-2.14.3-64- ...
- 用mathematica求六元一次方程组且方程个数比变量个数少一个
问题详见知乎:https://www.zhihu.com/question/68000713 我的问题:有5个方程,6个变量,其实我是想求出来de1=(系数)*dS1的形式,系数有Cij组成,Cij为 ...
- typecho 调用评论最多热门文章
在当前主题的functions.php文件中添加以下函数代码: function getHotComments($limit = 10){ $db = Typecho_Db::get(); $resu ...
- Grand Central Dispatch
什么是GCD? Grand Central Dispatch或者GCD,是一套低层API,提供了一种新的方法来进行并发程序编写.从基本功能上讲,GCD有点像NSOperationQueue,他们都允许 ...
- linux 个人配置记录
一.防火墙操作 1) 重启后生效 开启: chkconfig iptables on 关闭: chkconfig iptables off 2) 即时生效,重启后失效 开启: service ipta ...
- PAT甲级 1126. Eulerian Path (25)
1126. Eulerian Path (25) 时间限制 300 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue In grap ...
- POJ3111 K Best 2017-05-11 18:12 31人阅读 评论(0) 收藏
K Best Time Limit: 8000MS Memory Limit: 65536K Total Submissions: 10261 Accepted: 2644 Case Time ...
- HashMap原理、源码、实践
HashMap是一种十分常用的数据结构,作为一个应用开发人员,对其原理.实现的加深理解有助于更高效地进行数据存取.本文所用的jdk版本为1.5. 使用HashMap <Effective JAV ...
- OpenStack Kilo版加CEPH部署手册
OpenStack Kilo版加CEPH部署手册 作者: yz联系方式: QQ: 949587200日期: 2015-7-13版本: Kilo 转载地址: http://mp.weixin.qq.co ...
- 64位进程调用32位dll的解决方法
64位进程调用32位dll的解决方法 最近做在Windows XP X64,VS2005环境下做32位程序编译为64位程序的工作,遇到了一些64位编程中可能遇到的问题:如内联汇编(解决方法改为C/ ...