#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的更多相关文章

  1. POJ 2491 Scavenger Hunt map

    Scavenger Hunt Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 2848   Accepted: 1553 De ...

  2. POJ 3370. Halloween treats 抽屉原理 / 鸽巢原理

    Halloween treats Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 7644   Accepted: 2798 ...

  3. POJ 2356. Find a multiple 抽屉原理 / 鸽巢原理

    Find a multiple Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 7192   Accepted: 3138   ...

  4. POJ 2965. The Pilots Brothers' refrigerator 枚举or爆搜or分治

    The Pilots Brothers' refrigerator Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 22286 ...

  5. POJ 1753. Flip Game 枚举or爆搜+位压缩,或者高斯消元法

    Flip Game Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 37427   Accepted: 16288 Descr ...

  6. POJ 3254. Corn Fields 状态压缩DP (入门级)

    Corn Fields Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 9806   Accepted: 5185 Descr ...

  7. POJ 2739. Sum of Consecutive Prime Numbers

    Sum of Consecutive Prime Numbers Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 20050 ...

  8. POJ 2255. Tree Recovery

    Tree Recovery Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 11939   Accepted: 7493 De ...

  9. 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 ...

随机推荐

  1. python3.4连接mysql5.7数据库增删改查

    #!/usr/bin/env python # -*- coding:utf-8 -*- # __author__ = "blzhu" """ pyt ...

  2. DOM3级的变化

    由于存在跨浏览器开发问题所以不推荐使用: 兼容性: event.key 包含所按下键的字符 event.char 属性IE9和safari和chrome并不支持 event.location 返回所按 ...

  3. asp.net上传文件夹

    最近公司做工程项目,实现文件夹上传. 网上找了一天,发现网上很多代码都存在相似问题,最后终于找到了一个符合要求的项目. 工程如下: 这里对项目的文件夹上传进行分析,实现文件夹上传,如何进行文件夹上传. ...

  4. 07-css的继承性和层叠性

    css有两大特性:继承性和层叠性 继承性 面向对象语言都会存在继承的概念,在面向对象语言中,继承的特点:继承了父类的属性和方法.那么我们现在主要研究css,css就是在设置属性的.不会牵扯到方法的层面 ...

  5. 【Javascript第二重境界】序

    JS是个人比较喜欢的一门语言,在前端开发中也处于核心位置.前面断断续续的研究了一段时间,这其中包括 对象,原型,继承,函数,设计模式,模块,DOM操作,以及其它又多又琐碎的知识点,而且大部分内容都没有 ...

  6. Application-identifier entitlement does not match问题的解决

    以下是一个老外的回答: This happened to me after installing a build from TestFlight and overwriting it with the ...

  7. 阿里云服务器 OSS的使用限制

    使用限制 更新时间:2019-02-12 16:50:27 编辑 · OSS的使用限制及性能指标如下:   限制项 说明 归档存储 已经存储的数据从冷冻状态恢复到可读取状态需要 1 分钟的等待时间. ...

  8. Linux服务器数据备份恢复策略

    一.Linux 备份恢复基础 1.什么是备份 最简单的讲,备份数据的过程就是拷贝重要的数据到其他的介质之上(通常是可移动的),以保证在原始数据丢失的情况下可以恢复数据.一次备份可能是简单的 cp命令, ...

  9. PAT甲级 1120. Friend Numbers (20)

    1120. Friend Numbers (20) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue Two in ...

  10. python_运算符与表达式

    运算符与表达式 python运算符 运算符 功能说明 + 算术加法,列表.元组.字符串合并与连接,正号 - 算术减法,集合差集,相反数 * 算术乘法,序列重复 / 真除法 // 求整商,但如果操作数中 ...