ICM Technex 2017 and Codeforces Round #400 (Div. 1 + Div. 2, combined) A
Our beloved detective, Sherlock is currently trying to catch a serial killer who kills a person each day. Using his powers of deduction, he came to know that the killer has a strategy for selecting his next victim.
The killer starts with two potential victims on his first day, selects one of these two, kills selected victim and replaces him with a new person. He repeats this procedure each day. This way, each day he has two potential victims to choose from. Sherlock knows the initial two potential victims. Also, he knows the murder that happened on a particular day and the new person who replaced this victim.
You need to help him get all the pairs of potential victims at each day so that Sherlock can observe some pattern.
First line of input contains two names (length of each of them doesn't exceed 10), the two initials potential victims. Next line contains integer n(1 ≤ n ≤ 1000), the number of days.
Next n lines contains two names (length of each of them doesn't exceed 10), first being the person murdered on this day and the second being the one who replaced that person.
The input format is consistent, that is, a person murdered is guaranteed to be from the two potential victims at that time. Also, all the names are guaranteed to be distinct and consists of lowercase English letters.
Output n + 1 lines, the i-th line should contain the two persons from which the killer selects for the i-th murder. The (n + 1)-th line should contain the two persons from which the next victim is selected. In each line, the two names can be printed in any order.
ross rachel
4
ross joey
rachel phoebe
phoebe monica
monica chandler
ross rachel
joey rachel
joey phoebe
joey monica
joey chandler
icm codeforces
1
codeforces technex
icm codeforces
icm technex
In first example, the killer starts with ross and rachel.
- After day 1, ross is killed and joey appears.
- After day 2, rachel is killed and phoebe appears.
- After day 3, phoebe is killed and monica appears.
- After day 4, monica is killed and chandler appears.
题意:看样列
解法:没啥说的
#include<bits/stdc++.h>
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
using namespace std;
int main(){
string s1,s2;
cin>>s1>>s2;
cout<<s1<<" "<<s2<<endl;
int n;
cin>>n;
for(int i=;i<=n;i++){
string s3,s4;
cin>>s3>>s4;
if(s3==s1){
s1=s4;
}else{
s2=s4;
}
cout<<s1<<" "<<s2<<endl;
}
return ;
}
ICM Technex 2017 and Codeforces Round #400 (Div. 1 + Div. 2, combined) A的更多相关文章
- ICM Technex 2017 and Codeforces Round #400 (Div. 1 + Div. 2, combined) A map B贪心 C思路前缀
A. A Serial Killer time limit per test 2 seconds memory limit per test 256 megabytes input standard ...
- ICM Technex 2017 and Codeforces Round #400 (Div. 1 + Div. 2, combined) D. The Door Problem 2-SAT
题目链接:http://codeforces.com/contest/776/problem/D D. The Door Problem time limit per test 2 seconds m ...
- ICM Technex 2017 and Codeforces Round #400 (Div. 1 + Div. 2, combined)
前四题比较水,E我看出是欧拉函数傻逼题,但我傻逼不会,百度了下开始学,最后在加时的时候A掉了 AC:ABCDE Rank:182 Rating:2193+34->2227 终于橙了,不知道能待几 ...
- 【2-SAT】【并查集】ICM Technex 2017 and Codeforces Round #400 (Div. 1 + Div. 2, combined) D. The Door Problem
再来回顾一下2-SAT,把每个点拆点为是和非两个点,如果a能一定推出非b,则a->非b,其他情况同理. 然后跑强连通分量分解,保证a和非a不在同一个分量里面. 这题由于你建完图发现都是双向边,所 ...
- 【枚举】【前缀和】【map】ICM Technex 2017 and Codeforces Round #400 (Div. 1 + Div. 2, combined) C. Molly's Chemicals
处理出前缀和,枚举k的幂,然后从前往后枚举,把前面的前缀和都塞进map,可以方便的查询对于某个右端点,有多少个左端点满足该段区间的和为待查询的值. #include<cstdio> #in ...
- ICM Technex 2017 and Codeforces Round #400 (Div. 1 + Div. 2, combined) D
Moriarty has trapped n people in n distinct rooms in a hotel. Some rooms are locked, others are unlo ...
- ICM Technex 2017 and Codeforces Round #400 (Div. 1 + Div. 2, combined) C
Molly Hooper has n different kinds of chemicals arranged in a line. Each of the chemicals has an aff ...
- ICM Technex 2017 and Codeforces Round #400 (Div. 1 + Div. 2, combined) B
Sherlock has a new girlfriend (so unlike him!). Valentine's day is coming and he wants to gift her s ...
- ICM Technex 2017 and Codeforces Round #400 (Div. 1 + Div. 2, combined) C. Molly's Chemicals
感觉自己做有关区间的题目方面的思维异常的差...有时简单题都搞半天还完全没思路,,然后别人提示下立马就明白了...=_= 题意:给一个含有n个元素的数组和k,问存在多少个区间的和值为k的次方数. 题解 ...
随机推荐
- NOIP2015_提高组Day2_3_运输计划
这题思路很简单: 先对每个询问求距离,对距离由大到小排序, 二分最小距离,验证是否可行,验证时用差分处理: #include<iostream> #include<cstring&g ...
- Struts2 Action 匹配的几种方式
下面针对我所遇见的Action的配置方法进行一下总结: 1.基本的匹配方法
- Rsync+Inotify同步
rsync服务安装与<rsync+sersync同步>环境一样! 安装inotify-tools 在源服务器10.10.2.191上操作: 1.查看服务器内核是否支持inotify ll ...
- 数据表示Numpy
1 基本 1.1 基本介绍 掌握表示, 清洗, 统计和展示数据的能力 Numpy, Matplotlib, Pandas, Projects 摘要: 有损的提取数据特征的过程 可以将一组数据, 摘要出 ...
- vue-router 获得上一级路由以及返回上一级路由的方法
if (this.$store.state.previousRouter.name) { this.$router.push({name: this.$store.state.previousRout ...
- 用libtommath实现RSA算法
RSA算法描述: 1) 选择两个大素数 p.q, 计算 n = p*q; 2) 产生 e, d 使: e*d = 1mod(p-1)(q-1) e 与 (p-1)(q-1) 互质 [公钥] e.n [ ...
- JavaScript-Tool:jQuery
ylbtech-JavaScript-Tool:jQuery 1.返回顶部 1. jQuery是一个快速.简洁的JavaScript框架,是继Prototype之后又一个优秀的JavaScript代码 ...
- ascall文件和二进制文件
ascall文件可以打开让我们看你们的具体内容. 二进制文件打开我们看到的就是一堆乱码. ascall在换行时不同的平台不一样: windows上面用 \r\n linux上面用 \n 二进制的内容 ...
- 在windows64位的系统上面操作操作excel程序出现异常
1.把iis的网站程序引用池启用32位设置 2.把iis的网站程序引用池启用中标识修改为LocalSystem 2.代开cmd 输入mmc -32 添加组件服务在dcom组件中找到excel安全里添加 ...
- 后端开发-Mybatis开发之一
2018-12-29 Mybatis简单开发:我是在eclipse上进行Java项目开发 目录结构如下: 内容如下: mysql.sql: 用于创建测试用的数据库以及表: 可以直接导入mys ...