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的更多相关文章
随机推荐
- Java 日期加减
import java.text.SimpleDateFormat;import java.util.Calendar;import java.util.Date; public class Test ...
- maven添加仓库没有的jar包
mvn install:install-file -DgroupId=com.oracle -DartifactId=ojdbc14 -Dversion=10.2.0.4.0 -Dpackaging= ...
- 模仿 AppStore 顶部动画
App Store 顶部动画 App Store 中 Games.Apps.Updates 的顶部动画的特点: 自然状态下是大标题,右边有一个 button 顶上去时,变成小标题,右边按钮消失 导航栏 ...
- pythonweb框架Flask学习笔记04-模板继承
# -*- coding:utf-8 -*- from flask import render_template,Flask app=Flask(__name__) @app.route('/hell ...
- Eclipse启动和手动启动tomcat访问localhost:8080显示404问题总结
前言:建议对tomcat的文件结构和相关属性有较多了解.本文以eclipse的DynamicWebProject为讲解对象. 目录: eclipse添加tomcat关联注意点 tomcat404问题归 ...
- POJ 1101
#include <iostream> #include <string> #define MAXN 78 #define min _min #define inf 12345 ...
- (转)Mysql常用命令行
原文:http://www.cnblogs.com/TsengYuen/archive/2012/01/11/2319034.html Mysql常用命令行 Mysql经常使用号令行大全 熬头招.my ...
- Linux的shell script
Linux的shell script //编辑shell: vi a.sh //子进程运行shell sh a.sh //主线程运行shell source a.sh 相关例子: #!/bin/bas ...
- java数据结构之队列
队列概述队列是一种特殊的线性表,它只允许在表的前端(front)进行删除操作,而在表的后端(rear)进行插入操作.进行插入操作的端称为队尾,进行删除操作的端称为队头.队列中没有元素时,称为空队列.– ...
- echart 饼图数据为0不显示或者太小显示其他的解决办法
饼图数据为0或者太小显示如下,不美观 解决办法: 为0的去掉,小于0.005的累加起来 方法 function getsData(_rowData){ var rowData=JSON.parse(J ...