CodeForces765A
A. Neverending competitions
There are literally dozens of snooker competitions held each year, and team Jinotega tries to attend them all (for some reason they prefer name "snookah")! When a competition takes place somewhere far from their hometown, Ivan, Artsem and Konstantin take a flight to the contest and back.
Jinotega's best friends, team Base have found a list of their itinerary receipts with information about departure and arrival airports. Now they wonder, where is Jinotega now: at home or at some competition far away? They know that:
- this list contains all Jinotega's flights in this year (in arbitrary order),
- Jinotega has only flown from his hometown to a snooker contest and back,
- after each competition Jinotega flies back home (though they may attend a competition in one place several times),
- and finally, at the beginning of the year Jinotega was at home.
Please help them to determine Jinotega's location!
Input
In the first line of input there is a single integer n: the number of Jinotega's flights (1 ≤ n ≤ 100). In the second line there is a string of 3capital Latin letters: the name of Jinotega's home airport. In the next n lines there is flight information, one flight per line, in form "XXX->YYY", where "XXX" is the name of departure airport "YYY" is the name of arrival airport. Exactly one of these airports is Jinotega's home airport.
It is guaranteed that flights information is consistent with the knowledge of Jinotega's friends, which is described in the main part of the statement.
Output
If Jinotega is now at home, print "home" (without quotes), otherwise print "contest".
Examples
input
4
SVO
SVO->CDG
LHR->SVO
SVO->LHR
CDG->SVO
output
home
input
3
SVO
SVO->HKT
HKT->SVO
SVO->RAP
output
contest
Note
In the first sample Jinotega might first fly from SVO to CDG and back, and then from SVO to LHR and back, so now they should be at home. In the second sample Jinotega must now be at RAP because a flight from RAP back to SVO is not on the list.
//2017-02-14
#include <iostream>
#include <cstdio>
#include <cstring> using namespace std; int main()
{
int n, cnt1, cnt2;
string src, line;
while(cin>>n)
{
cnt1 = ;
cnt2 = ;
cin >> src;
for(int i = ; i < n; i++)
{
cin>>line;
if(src[]==line[]&&src[]==line[]&&src[]==line[])cnt1++;
if(src[]==line[]&&src[]==line[]&&src[]==line[])cnt2++;
}
if(cnt1==cnt2)cout<<"home"<<endl;
else cout<<"contest"<<endl;
} return ;
}
CodeForces765A的更多相关文章
随机推荐
- jzoj5848
小 S 热爱大自然, 一天他种了一棵奇怪的线段树. 奇怪的线段树是一种与普通线段树类似的结构, 唯一不同的是, 它不一定以每一个区间的中点作为分治中心. 麻烦的是, 小 S 的线段树被风吹散了, 散成 ...
- Smarty的原理_面试
Smarty是一个模板引擎,使用smarty主要是为了实现逻辑和外在内容的分离,如果不使用模板的话,通常的做法就是php代码和html代码混编.使用了模板后,则可以将业务逻辑放到php文件中,而负责显 ...
- webpack快速入门——配置文件:入口和出口,多入口、多出口配置
1.在根目录新建一个webpack.config.js文件,然后开始配置: const path = require('path'); module.exports={ //入口文件的配置项 entr ...
- spring定时任务的注解实现方式
STEP 1:在spring配置文件中添加相应配置,以支持定时任务的注解实现 (一)在xml里加入task的命名空间 <!-- beans里添加:--> xmlns:task=" ...
- php 中的查找算法 和 排序方法(多字段排序)
一.查找算法 1.顺序查找(一个一个查,效率低,不用多说) 2.二分查找 /* php 二分查找 在$a数组里查找$x的位置 $a必须是一个以升序排序后的数组 */ function binsearc ...
- ios实现fastlane自动化打包
终于抽出时间来学习自动化打包了,app在测试阶段一天总会经历好几次的打包,每次打包真是身心疲惫,刚打完的包说不定就被测试妹子反应还要微调什么地方,我就真的有气没法出,打一次包怎么也得浪费十几分钟,还不 ...
- java异常层次机构图
以下内容转自:http://www.cnblogs.com/toSeeMyDream/p/5213610.html 在Java中,异常分为受检查的异常,与运行时异常. 两者都在异常类层次结构中.下面的 ...
- 剑指offer三十九之平衡二叉树
一.题目 输入一棵二叉树,判断该二叉树是否是平衡二叉树. 二.思路 详解代码. 三.代码 public class Solution { //判断根节点左右子树的深度,高度差超过1,则不平衡 ...
- web worker原理 && SSE原理
第一部分 什么是 web worker? 我们一直强调JavaScript是单线程的,但是web worker的出现使得JavaScript可以在多线程上跑,只是web worker本身适合用于一些复 ...
- 【Java并发编程】:并发新特性—Lock锁和条件变量
简单使用Lock锁 Java5中引入了新的锁机制——Java.util.concurrent.locks中的显式的互斥锁:Lock接口,它提供了比synchronized更加广泛的锁定操作.Lock接 ...