Problem description

As you may know, MemSQL has American offices in both San Francisco and Seattle. Being a manager in the company, you travel a lot between the two cities, always by plane.

You prefer flying from Seattle to San Francisco than in the other direction, because it's warmer in San Francisco. You are so busy that you don't remember the number of flights you have made in either direction. However, for each of the last n days you know whether you were in San Francisco office or in Seattle office. You always fly at nights, so you never were at both offices on the same day. Given this information, determine if you flew more times from Seattle to San Francisco during the last n days, or not.

Input

The first line of input contains single integer n (2 ≤ n ≤ 100) — the number of days.

The second line contains a string of length n consisting of only capital 'S' and 'F' letters. If the i-th letter is 'S', then you were in Seattle office on that day. Otherwise you were in San Francisco. The days are given in chronological order, i.e. today is the last day in this sequence.

Output

Print "YES" if you flew more times from Seattle to San Francisco, and "NO" otherwise.

You can print each letter in any case (upper or lower).

Examples

Input

  1. 4
    FSSF

Output

  1. NO

Input

  1. 2
    SF

Output

  1. YES

Input

  1. 10
    FFFFFFFFFF

Output

  1. NO

Input

  1. 10
    SSFFSFFSFF

Output

  1. YES

Note

In the first example you were initially at San Francisco, then flew to Seattle, were there for two days and returned to San Francisco. You made one flight in each direction, so the answer is "NO".

In the second example you just flew from Seattle to San Francisco, so the answer is "YES".

In the third example you stayed the whole period in San Francisco, so the answer is "NO".

In the fourth example if you replace 'S' with ones, and 'F' with zeros, you'll get the first few digits of π in binary representation. Not very useful information though.

解题思路:题目的意思就是如果字符串中S->F字符变化次数大于F->S的变化次数,则为"YES",否则为"NO",简单处理字符串!

AC代码:

  1. #include<bits/stdc++.h>
  2. typedef long long LL;
  3. using namespace std;
  4. int main(){
  5. int n,i=,t1=,t2=;char s[];//t1表示S->F的变化次数,t2表示F->S的变化次数
  6. cin>>n;getchar();//吃掉回车符对字符串的影响
  7. cin>>s;
  8. while(s[i]!='\0'){
  9. if(s[i]=='S'){
  10. while(s[i]=='S')i++;
  11. if(s[i]!='\0')t1++;//不到末尾才可以加1,因为字符串中只有两个字符,既不是结束符,也跳出了上一步的循环,说明接下来的字符必为'F',则t1加1
  12. }
  13. else{
  14. while(s[i]=='F')i++;
  15. if(s[i]!='\0')t2++;//理由同上
  16. }
  17. }
  18. if(t1>t2)cout<<"YES"<<endl;
  19. else cout<<"NO"<<endl;
  20. return ;
  21. }

C - Between the Offices的更多相关文章

  1. 如何去破解所有的window和offices(超级全面)

    破解所有的Windows和Offices by方阳 版权声明:本文为博主原创文章,转载请指明转载地址 http://www.cnblogs.com/fydeblog/p/7107666.html  摘 ...

  2. offices 激活

    http://www.xitongcheng.com/jiaocheng/dnrj_article_44577.html  破解工具见cnblos文件中 : https://blog.csdn.net ...

  3. LA4273 Post Offices

    题目戳这里. 村庄排序.状态\(f[j][i]\)表示考虑前\(i\)个村庄,造\(j\)个邮局且\(i\)造了邮局的最小代价.我们用\(Lb_i,Rb_i\)表示在第\(i\)个村庄造邮局,邮局最左 ...

  4. 【Codeforces Round #437 (Div. 2) A】Between the Offices

    [链接]h在这里写链接 [题意] 在这里写题意 [题解] 在这里写题解 [错的次数] 0 [反思] 在这了写反思 [代码] #include <bits/stdc++.h> using n ...

  5. 【12-26】go.js

    var $ = go.GraphObject.make; // for conciseness in defining templates function buildAlarm(row,column ...

  6. HDOJ 4770 Lights Against Dudely

    状压+暴力搜索 Lights Against Dudely Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K ...

  7. POJ 1160 题解

    Post Office Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 18835   Accepted: 10158 Des ...

  8. Java基础之类Class使用

    大家都知道Java是一门面向对象编程语言,在Java世界里,万事万物皆对象,那个Java中怎么表示对象呢?Class 我们知道Java中的对象都是Object类的子类,那么今天我们就一起来研究一下Ja ...

  9. Sharepoint学习笔记—习题系列--70-576习题解析 -(Q128-Q130)

    Question  128 You are designing a SharePoint 2010 solution that includes a custom site definition an ...

随机推荐

  1. Enable ssh root login in Solaris

    1. Change the file /etc/ssh/sshd_config with PermitRootLogin yes to replace PermitRootLogin no 2. re ...

  2. Codeforces Round #469 Div. 2题解

    A. Left-handers, Right-handers and Ambidexters time limit per test 1 second memory limit per test 25 ...

  3. java面试题(转)

    1.面向对象的特征有哪些方面?答:面向对象的特征主要有以下几个方面:- 抽象:抽象是将一类对象的共同特征总结出来构造类的过程,包括数据抽象和行为抽象两方面.抽象只关注对象有哪些属性和行为,并不关注这些 ...

  4. linux学习1-基础知识

    1.输入一行字跳到行头 ctrl+a:跳到行尾 ctrl+e: 2.一次创建多个文件 touch love_{1..10}_linux.txt touch love_{1,3,5}_linux.txt ...

  5. 【Codeforces 27A】Next Test

    [链接] 我是链接,点我呀:) [题意] 让你求没出现过的最小值 [题解] 模拟..for一下就好 [代码] import java.io.*; import java.util.*; public ...

  6. Square words(codevs 3301)

    题目描述 Description 定义square words为: 1.长度为偶数. 2.前一半等于后一半. 比如abcabc和aaaa都是square words,但是abcabcab和aaaaa都 ...

  7. FFmpeg基础库编程开发学习笔记——音频常见格式及字幕格式

    声明一下:这些关于ffmpeg的文章仅仅是用于记录我的学习历程和以便于以后查阅,文章中的一些文字可能是直接摘自于其它文章.书籍或者文献,学习ffmpeg相关知识是为了使用在Android上,我也才是刚 ...

  8. Eclipse启动时提示fail to create the Java Virtual Machine问题的解决

    今天偶然打开Eclipse.发现无法打开,出现例如以下提示: 后来经过上网查询.发现是eclipse.ini文件的问题,打开eclipse安装文件夹下的eclipse.ini文件: -startup ...

  9. css3 动态背景

    动态背景 利用多层背景的交替淡入淡出,实现一种背景在不停变换的效果,先看图. 效果图: DEMO地址 步骤 1.利用css的radial-gradient创建一个镜像渐变的背景.当中的80% 20%为 ...

  10. Atitit. C# java 的api 文件夹封装结构映射总结

    Atitit. C#  java 的api 文件夹封装结构映射总结 C# java ref System.Reflection System.Type. java.lang.ref concurren ...