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 ...
随机推荐
- 2018.10.23 hdu2476String painter(区间dp)
传送门 一道挺妙的区间dp. 我们先用区间dp求出第一个串为空串时的最小代价. 然后再加入原本的字符更新答案就行了. 代码: #include<bits/stdc++.h> using n ...
- 假期训练五(poj-1077bfs+康拓展开,hdu-2577dp)
题目一:传送门 思路:主要是找到状态, 考虑字母有两种状态,大写和小写, 从小写变为大写的变化方式有两种:保持cap状态,或者按住shift键: 从小写变为大写也有一种变化方式:按住shift键: 看 ...
- hadoop配置分区
1.运行MR,得出HDFS路径下数据 2.创建 Hive 表 映射 HDFS下的数据 3.为数据创建分区,在hive下执行 source 分区表: TIPS:结果集的时间,必须在分区范围内: 可以理解 ...
- 关于SQL表字段值缺失的处理办法
在计算收益率时候, 收益率 = 收益 / 成本 一.如果成本为0,NULL,此时无法计算收益率: 方法: 1.将成本为0的数据 运算 (case when cost =0 or cost is n ...
- Silverlight子窗口(ChildWindow)传递参数到父窗口演示
在企业级项目中,子窗口(ChildWindow)是一个常用控件,其展示方式是以弹出窗口来显示信息. 这里我将演示,子窗口传递参数到父窗口的方法.由于我的开发环境都是英文环境,所以部分中文可能显示不正常 ...
- (转)Application, Session, Cookie, Viewstate, Cache对象用法和区别
================================================================================ 1.Applicati ...
- (概率 01背包) Just another Robbery -- LightOJ -- 1079
http://lightoj.com/volume_showproblem.php?problem=1079 Just another Robbery As Harry Potter series i ...
- (DFS)展开字符串 -- hdu -- 1274
http://acm.hdu.edu.cn/showproblem.php?pid=1274 展开字符串 Time Limit: 2000/1000 MS (Java/Others) Memor ...
- File类、文件过滤器、递归、文件及文件夹的操作方法
一.File Io概述: 当需要把内存中的数据存储到持久化设备上这个动作称为输出(写)Output操作. 当把持久设备上的数据读取到内存中的这个动作称为输入(读)Input操作. 因此我们把这种输入和 ...
- Codeforces822 B. Crossword solving
B. Crossword solving time limit per test 1 second memory limit per test 256 megabytes input standard ...