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的更多相关文章
随机推荐
- Python 将一个已知的 utc时间字符串 转换为东八区时间
先获取一个utc格式的时间 utc_time = datetime.datetime.utcnow() print(utc_time) 输出 2018-06-24T08:59:39Z 这里我们假设目前 ...
- hdu4462--曼哈顿距离
题目大意:有N*N个点的田野,然后有k个点是用来放稻草人的,每个稻草人对周围满足曼哈顿距离的庄稼有保护作用 问最小的稻草人的个数能够保护所有庄稼,如果不能保护则输出-1 注意的地方: 1.放稻草人的点 ...
- jvm高级特性(1)(内存泄漏实例)
jvm内存结构回顾: .8同1.7比,最大的差别就是:元数据区取代了永久代.元空间的本质和永久代类似,都是对JVM规范中方法区的实现. 不过元空间与永久代之间最大的区别在于:元数据空间并不在虚拟机中, ...
- chrome inspect 远程调试H5
chrome://inspect/#devices 一个内置于chrome的远程调试指令,满足远程调试的几个必须条件 1,能够访问https://chrome-devtools-frontend.ap ...
- 【xsy1214】 异或路径(xorpath) 点分治+可持久化trie
题目大意:给你一棵$n$个点的树,每个点有一个点权$x$,问你所有路径中点权异或和最大的路径的异或和 数据范围:$n≤30000$,$x≤2^{31}-1$. 如果是边上有点权的话非常简单,直接一个$ ...
- 【PKUSC2018】【loj6433】最大前缀和 状压dp
这题吼啊... 然而还是想了$2h$,写了$1h$. 我们发现一个性质:若一个序列$p$能作为前缀和,那么在序列$p$中,包含序列$p$最后一个数的所有子序列必然都是非负的. 那么,我们 令$f[i] ...
- eolinker接口测试平台的安装部署
1.从GitHub下载安装包: https://github.com/eolinker/CHN-EOLINKER-AMS-Lite-4.0-For-Java 使用 git clone https:// ...
- 目录打散-hash算法
前几篇说了文件上传,都是上传到了WebRoot下的up目录,这样是不行的,文件多了性能就不行了.文件一般都是分目录存放的,这里讲建目录的一种算法.先看结果,经过本算法建的目录,结构是这样的,还以up目 ...
- Vue中父组件向子组件传值
Vue中父组件向子组件传值 相关Html: <!DOCTYPE html> <html lang="en"> <head> <meta c ...
- php输出大段代码(含变量和方法)
echo<<<EOF <html> <body> <formname="MainForm"method="post&quo ...