CF867A.Between the Offices

入门

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

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.

你可能知道,MemSQL 公司在美国旧金山和西雅图均设有办事处。作为公司的一名经理,你经常需要在这两座城市之间往返,且始终乘坐飞机。

你更喜欢从西雅图飞往旧金山,因为旧金山的天气更暖和。由于工作非常繁忙,你不记得自己在任一方向上已飞行了多少次。然而,对于最近的 nn 天,你知道每天你是在旧金山办事处还是在西雅图办事处。你总是在夜间乘机,因此你绝不会在同一天出现在两个办事处。根据这一信息,请判断:在最近的 nn 天中,你从西雅图飞往旧金山的次数是否多于反方向的次数。

输入格式

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.

输入的第一行包含一个整数 nn(2≤n≤1002 \leq n \leq 100)—— 表示天数。

第二行包含一个长度为 nn 的字符串,仅由大写字母 'S' 和 'F' 组成。如果第 ii 个字符是 'S',则表示你在当天位于西雅图(Seattle)办公室;否则你位于旧金山(San Francisco)办公室。这些天按时间顺序给出,即序列中的最后一天为今天。

输出格式

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).

如果从西雅图飞往旧金山的次数更多,则输出 "YES",否则输出 "NO"。

您可以以任意大小写(大写或小写)输出每个字母。

输入输出样例

  • 输入#1

    4
    FSSF

    输出#1

    NO
  • 输入#2

    2
    SF

    输出#2

    YES
  • 输入#3

    10
    FFFFFFFFFF

    输出#3

    NO
  • 输入#4

    10
    SSFFSFFSFF

    输出#4

    YES

说明/提示

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.

在第一个例子中,你最初位于旧金山,然后飞往西雅图,在那里停留了两天,再返回旧金山。你在每个方向上各进行了一次飞行,因此答案是“NO”。

在第二个例子中,你仅从西雅图飞往旧金山,因此答案是“YES”。

在第三个例子中,你整个期间都待在旧金山,因此答案是“NO”。

在第四个例子中,若将 'S' 替换为 1,'F' 替换为 0,你将得到 π 的二进制表示的前几位数字。不过,这并不是很有用的信息。

输入解题思路,AI测评打分。不知道怎么写?

首页