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的更多相关文章
随机推荐
- 设置jade高亮
来自:https://segmentfault.com/a/1190000002896247 打开sublime3,再打开 view > show console,把下列代码复制到console ...
- Sysbench0.5初体验
最近工作中需要测试数据库的OLTP的性能,参考了下MariaDB的benchmark中的测试脚本,发现脚本中已经使用了Sysbench-0.5,可以在这里https://launchpad.net/s ...
- [Auto Testing] 工具准备:Selenium 与 ChromeDriver
<留存> Selenium http://selenium-release.storage.googleapis.com/index.html https://www.seleniumhq ...
- 线程TLAB局部缓存区域(Thread Local Allocation Buffer)
TLAB(Thread Local Allocation Buffer) 1,堆是JVM中所有线程共享的,因此在其上进行对象内存的分配均需要进行加锁,这也导致了new对象的开销是比较大的 2,Sun ...
- cms的使用与总结
1,把cms中的basecms复制进Wamp里面的www文件夹, 2,打开Wamp,打开网址http://localhost/basecms/core/admin/admin.php(该网址默认端口为 ...
- chrome下uploadify导致页面崩溃
解决方法在初始化uploadify之前用timeout来延迟加载 $(function(){ setTimeout(function(){ $('#file_upload'). ...
- (转)inspect — Inspect live objects
原文:https://docs.python.org/3/library/inspect.html 中文:https://www.rddoc.com/doc/Python/3.6.0/zh/libra ...
- 《Algorithms算法》笔记:优先队列(1)——API和初等实现
1.优先队列的API和初等实现 做一个总结: 栈 :先进后出 队列 :先进先出 随机队列 : 随机出 优先队列:每次出来的是最大值或最小值 1.1优先队列的API 优先队列在很多场合都有用, 比如:在 ...
- Android输入控件EditText和软键盘监听
1. 跳转到新的页面自动软键盘显示情况: 在配置清单文件AndroidManifest.xml文件,对Activity的windowSoftInputMode属性进行设置. stateUnspecif ...
- JS - 解决鼠标单击、双击事件冲突问题(原生js实现)
由于鼠标双击时每一次触发双击事件都会引起两次单击事件和一次单击事件,原生的js不提供专门的双击事件. 因为业务原因,双击和单机都绑定了不同的业务,在双击的时候又触发了单机,影响了页面的正常显示 出现问 ...