765A Neverending competitions
2 seconds
512 megabytes
standard input
standard output
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!
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.
If Jinotega is now at home, print "home" (without quotes), otherwise print "contest".
4
SVO
SVO->CDG
LHR->SVO
SVO->LHR
CDG->SVO
home
3
SVO
SVO->HKT
HKT->SVO
SVO->RAP
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.
#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 ;
}
765A Neverending competitions的更多相关文章
- Codeforces Round #397 by Kaspersky Lab and Barcelona Bootcamp (Div. 1 + Div. 2 combined) A. Neverending competitions 水题
A. Neverending competitions 题目连接: http://codeforces.com/contest/765/problem/A Description There are ...
- Codeforces Round #397 by Kaspersky Lab and Barcelona Bootcamp (Div. 1 + Div. 2 combined) A - Neverending competitions
地址:http://codeforces.com/contest/765/problem/A 题目: A. Neverending competitions time limit per test 2 ...
- 【codeforces 765A】Neverending competitions
[题目链接]:http://codeforces.com/contest/765/problem/A [题意] 给你一个人的n个行程 行程都是从家到某个地方或从某个地方到家; 且是无序的,且如果到了非 ...
- Codeforces Round #397 by Kaspersky Lab and Barcelona Bootcamp (Div. 1 + Div. 2 combined)
运气好,分到的房里我最先开始Hack C题,Hack了12个,听说F题沙雕莫队但我不会,最后剩不到15分钟想出E题做法打了一波结果挂了,最后虽然上分了但总有点不甘心. 最后A掉ABCD Hack+12 ...
- CodeForces765A
A. Neverending competitions time limit per test:2 seconds memory limit per test:512 megabytes input: ...
- Codeforces Round #397 by Kaspersky Lab and Barcelona Bootcamp (Div. 1 + Div. 2 combined) A B C D 水 模拟 构造
A. Neverending competitions time limit per test 2 seconds memory limit per test 512 megabytes input ...
- Codeforces Round #397 题解
Problem A. Neverending competitions 题目大意 一个团队有多个比赛,每次去比赛都会先订机票去比赛地点,然后再订机票返回.给出\(n\)个含有起止地点的购票记录(不按时 ...
- Improving your submission -- Kaggle Competitions
1: Improving Our Features In the last mission, we made our first submission to Titanic: Machine Lear ...
- Getting started with Kaggle -- Kaggle Competitions
1: The Competition We'll be learning how to generate a submission for a Kaggle competition. Kaggle i ...
随机推荐
- 1. SVN clean失败解决方法
svn执行clean up后出现提示:svn cleanup failed–previous operation has not finished; run cleanup if it was int ...
- 77. sqlserver 锁表解决方式
select request_session_id spid, OBJECT_NAME(resource_associated_entity_id) tableName from sys.dm_tra ...
- leetcode342
public class Solution { public bool IsPowerOfFour(int num) { ) && ((num & (num - )) == ) ...
- 去除android手机浏览器中, 按住链接出现border的情况
body{ -moz-user-select:none; -webkit-user-select:none; -webkit-tap-highlight-color:transparent; }
- 机器学习入门-集成算法(bagging, boosting, stacking)
目的:为了让训练效果更好 bagging:是一种并行的算法,训练多个分类器,取最终结果的平均值 f(x) = 1/M∑fm(x) boosting: 是一种串行的算法,根据前一次的结果,进行加权来提高 ...
- mime设置
ie9对mime有特殊要求,必须要有type才可以. 如果出现css的mime类型不支持.则没有加 type="css/text" 查看本机的mime支持: regedit > ...
- windows与linux环境查看jdk安装路径
windows: set java_home 查看jdk安装路径 java -version 查看jdk版本 linux: whereis java which java(java执行路径) echo ...
- xslt基础学习
今天下午工作完成没事,登w3c的网站学习了一下xslt的基础知识,主要是因为工作中xml用的比较多,xslt也有用到,所以在这里学习一下. XSLT:一种用于转换 XML 文档的语言. XSLT 用于 ...
- Optimizing graphics performance
看U3D文档,心得:对于3D场景,使用分层次的距离裁剪,小物件分到一个层,稍远时就被裁掉,大物体分到一个层,距离很远时才裁掉,甚至不载.中物体介于二者之间. 文档如下: Good performanc ...
- ArcGIS案例学习笔记1_1
ArcGIS案例学习笔记1_1 联系方式:谢老师,135_4855_4328, xiexiaokui#qq.com 时间:第一天上午 准备 0.U盘复制ArcGIS培训*** 1.练习数据不要放到桌面 ...