#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. 将驼峰转化为下化线(将型如AbcDef转化为abc_def)

    strtolower(preg_replace('/((?<=[a-z])(?=[A-Z]))/', '_', 'AbcDef'))

  2. linux 安装 ORACLE JDK 8

    1.卸载默认的OPENJDK 查看 open jdk 的安装 rpm -qa | grep java 卸载 openjdk rpm -e --nodeps java-1.7.0-openjdk-1.7 ...

  3. vue路由跳转的多种方式

    1.router-link to 跳转 <router-link to="/child"><button>跳转</button></rou ...

  4. (8)What makes a good life? Lessons from the longest study on happiness

    https://www.ted.com/talks/robert_waldinger_what_makes_a_good_life_lessons_from_the_longest_study_on_ ...

  5. 查看mysql数据库中的所有用户

    SELECT DISTINCT CONCAT('User: ''',user,'''@''',host,''';') AS query FROM mysql.user; @前面为用户名,后面对应的‘% ...

  6. gj12-2 协程和异步io

    12.3 epoll+回调+事件循环方式url import socket from urllib.parse import urlparse # 使用非阻塞io完成http请求 def get_ur ...

  7. s4-9 二层设备

    二层(数据链路层)设备有哪些?  网卡  网桥  交换机 NIC 网卡  Nework Interface Card  为主机提供介质的访问.  MAC地址烧在网卡的 ROM中 NIC 网 ...

  8. 【慕课网实战】Spark Streaming实时流处理项目实战笔记一之铭文升级版

    第一章:课程介绍 铭文一级: VMware Fusion Mac上搭建:为了给大家演示如何使用我们的OOTB环境 Hadoop环境:虚拟机,我是远程登录 Mac 那么就不需要使用我们的OOTB环境 V ...

  9. 深入浅出javascript(三)封装和继承

    一.私有变量和公有变量 通过var修饰的是私有变量. 二.私有变量的访问方法 三.特权.公有和私有方法 一个例子: function f(name) { var name=name; //私有变量 t ...

  10. HtmlControls和Webcontrols命名空间的区别

    HtmlControls(以下简称HC)是对大部分Html标签的复制,这些标签原来是什么样,经过服务器解释后的HC就是什么样.要使用HC,只需要在相应的html标签内加上runat=“server”属 ...