Codeforces Round #437 (Div. 2, based on MemSQL Start[c]UP 3.0 - Round 2) A.Between the Offices

A.Between the Offices

Problem statement

    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

Examples 1
input
4
FSSF
output
NO
Examples 2
input
2
SF
output
YES
Examples 3
input
10
FFFFFFFFFF
output
NO
Examples 4
input
10
SSFFSFFSFF
output
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,如果相邻两个字符不一样,若前一个为S,后一个为F,表示从S市飞到F市,相反则是从F市飞到S市,问你从S市飞到F市的次数是不是多于从F市飞到S市的次数。

思路

这题没啥好说的..就是直接暴力扫一遍就行了

Code

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
inline void readInt(int &x) {
    x=0;int f=1;char ch=getchar();
    while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
    while(isdigit(ch))x=x*10+ch-'0',ch=getchar();
    x*=f;
}
inline void readLong(ll &x) {
    x=0;int f=1;char ch=getchar();
    while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
    while(isdigit(ch))x=x*10+ch-'0',ch=getchar();
    x*=f;
}
/*================Header Template==============*/
string s;
int a,b,n;
int main() {
    cin>>n;
    cin>>s;
    for(int i=0;i<s.length()-1;i++) {
        if(s[i]==s[i+1])
            continue;
        else {
            if(s[i]=='F')
                a++;
            else
                b++;
        }
    }
    if(b>a)
        puts("YES");
    else
        puts("NO");
    return 0;
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值