CF765A.Neverending competitions
入门
通过率:0%
时间限制:2.00s
内存限制:512MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
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!
每年实际上会举办数十场斯诺克比赛,而 Jinotega 队伍力求参加全部比赛(出于某种原因,他们更喜欢将这项运动称为“snookah”)!当某场比赛在远离他们家乡的地方举行时,Ivan、Artsem 和 Konstantin 便会乘飞机前往比赛地,再乘飞机返回。
Jinotega 最好的朋友——Base 队伍——找到了一份 Jinotega 本年度行程收据清单,其中记录了每次航班的出发机场与到达机场。现在他们想知道:Jinotega 此刻身在何处?是在家乡,还是远在某场比赛地?他们已知以下信息:
- 这份清单包含了 Jinotega 本年度所有的航班(顺序任意);
- Jinotega 仅从家乡飞往斯诺克比赛地,再从比赛地飞回家乡;
- 每次比赛结束后,Jinotega 均会飞回家乡(尽管他们可能多次参加同一地点的比赛);
- 最后,本年度伊始,Jinotega 身处家乡。
请帮助他们判断 Jinotega 当前的位置!
输入格式
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 3 capital 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.
输入的第一行包含一个整数 n:金诺特加(Jinotega)的航班数量(1≤n≤100)。
第二行包含一个由 3 个大写拉丁字母组成的字符串:金诺特加的家乡机场名称。
接下来的 n 行中,每行包含一条航班信息,格式为 "XXX->YYY",其中 "XXX" 是出发机场的名称,"YYY" 是到达机场的名称。这两个机场中恰好有一个是金诺特加的家乡机场。
保证航班信息与金诺特加朋友们所掌握的知识一致,该知识已在题目主体部分中描述。
输出格式
If Jinotega is now at home, print "home" (without quotes), otherwise print "contest".
如果吉诺特加现在在家,则输出 home(不带引号),否则输出 contest。
输入输出样例
输入#1
4 SVO SVO->CDG LHR->SVO SVO->LHR CDG->SVO
输出#1
home
输入#2
3 SVO SVO->HKT HKT->SVO SVO->RAP
输出#2
contest
说明/提示
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.
在第一个样例中,Jinotega 可能先从 SVO 飞往 CDG 再返回,然后从 SVO 飞往 LHR 再返回,因此此时他们应已回到家中。在第二个样例中,Jinotega 此时必定位于 RAP,因为从 RAP 返回 SVO 的航班并未列在航班列表中。
输入解题思路,AI测评打分。不知道怎么写?