Codeforces Round #397 by Kaspersky Lab and Barcelona Bootcamp (Div. 1 + Div. 2 combined) A
Description
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.
题意:告诉我们飞机的航班流程,年初在家,(注意题目说从家里出发是会回来的)最后问我们,他是在home还是contest
解法:既然从家里出发会返回,那么我们只要比较出现家的次数奇偶性就行,偶数就是在家,奇数就是还没有回来
#include<bits/stdc++.h>
using namespace std;
int n;
char s1[],s2[];
int main()
{
int ans=;
cin>>n;
scanf("%s",s1);
for(int i=;i<n;i++)
{
scanf("%s",s2);
if(strstr(s2,s1)!=NULL)
{
ans++;
}
}
if(ans%)
{
cout<<"contest";
}
else
{
cout<<"home";
}
return ;
}
Codeforces Round #397 by Kaspersky Lab and Barcelona Bootcamp (Div. 1 + Div. 2 combined) A的更多相关文章
- Codeforces Round #397 by Kaspersky Lab and Barcelona Bootcamp (Div. 1 + Div. 2 combined) F. Souvenirs 线段树套set
F. Souvenirs 题目连接: http://codeforces.com/contest/765/problem/F Description Artsem is on vacation and ...
- Codeforces Round #397 by Kaspersky Lab and Barcelona Bootcamp (Div. 1 + Div. 2 combined) E. Tree Folding 拓扑排序
E. Tree Folding 题目连接: http://codeforces.com/contest/765/problem/E Description Vanya wants to minimiz ...
- Codeforces Round #397 by Kaspersky Lab and Barcelona Bootcamp (Div. 1 + Div. 2 combined) D. Artsem and Saunders 数学 构造
D. Artsem and Saunders 题目连接: http://codeforces.com/contest/765/problem/D Description Artsem has a fr ...
- Codeforces Round #397 by Kaspersky Lab and Barcelona Bootcamp (Div. 1 + Div. 2 combined) C. Table Tennis Game 2 水题
C. Table Tennis Game 2 题目连接: http://codeforces.com/contest/765/problem/C Description Misha and Vanya ...
- Codeforces Round #397 by Kaspersky Lab and Barcelona Bootcamp (Div. 1 + Div. 2 combined) B. Code obfuscation 水题
B. Code obfuscation 题目连接: http://codeforces.com/contest/765/problem/B Description Kostya likes Codef ...
- 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 B C D 水 模拟 构造
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) E. Tree Folding
地址:http://codeforces.com/contest/765/problem/E 题目: E. Tree Folding time limit per test 2 seconds mem ...
- Codeforces Round #397 by Kaspersky Lab and Barcelona Bootcamp (Div. 1 + Div. 2 combined) D. Artsem and Saunders
地址:http://codeforces.com/contest/765/problem/D 题目: D. Artsem and Saunders time limit per test 2 seco ...
- Codeforces Round #397 by Kaspersky Lab and Barcelona Bootcamp (Div. 1 + Div. 2 combined) C - Table Tennis Game 2
地址:http://codeforces.com/contest/765/problem/C 题目: C. Table Tennis Game 2 time limit per test 2 seco ...
随机推荐
- spring+mybatis项目整合
前辈总结的很详细,贴出链接,参考学习 http://www.open-open.com/lib/view/open1392252233301.html
- java反射技术实例
java反射技术实例1. [代码][Java]代码 package com.gufengxiachen.java.reflectiontest; public class Person {p ...
- android布局中使用include及需注意点
在android布局中,使用include,将另一个xml文件引入,可作为布局的一部分,但在使用include时,需注意以下问题: 一.使用include引入 如现有标题栏布局block_header ...
- laravel基础课程---1、laravel安装及基础介绍(laravel如何安装)
laravel基础课程---1.laravel安装及基础介绍(laravel如何安装) 一.总结 一句话总结: [修改composer镜像地址].[明确laravel的安装要求].[安装指定版本的la ...
- [转]text和content方法的区别
r.text str #字符串方式的响应体,会自动根据响应头部的 字符编码进行解码 r.content bytes #字节方式的响应体,会自动为你解码 gzip 和 deflate 压缩 reques ...
- Java版本更新历史(ing)
历史版本特性 JDK Version 1.0 开发代号为Oak(橡树),于1996-01-23发行. JDK Version 1.1 于1997-02-19发行. 引入的新特性包括: 引入JDBC(J ...
- hdu-2157 How many ways??(矩阵快速幂)
题目链接: How many ways?? Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/O ...
- Lucas定理和扩展Lucas定理
1.Lucas定理 首先给出式子:\(C_n^m\%p = C_{\lfloor\frac{n}{p}\rfloor}^{\lfloor\frac{m}{p}\rfloor} * C_{n\%p}^{ ...
- Map容器线程安全问题
一.HashMap在非线程安全的环境下使用会出现什么样的问题? public class HashMapMultiThread { static Map<String,String> ma ...
- ADB命令小结
)adb devices //查看启动的所有设备 )adb kill-server //重启设备 )adb start-server //启动设备 )adb -s emulator-(通过 adb d ...