Codeforces Round #437 (Div. 2, based on MemSQL Start[c]UP 3.0 - Round 2) A.Between the Offices
2017-10-02 15:56
513 查看
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 Sand 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 1input
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; }
相关文章推荐
- Codeforces Round #437 (Div. 2, based on MemSQL Start[c]UP 3.0 - Round 2) B.Save the Problem!
- Codeforces Round #437 (Div. 2, based on MemSQL Start[c]UP 3.0 - Round 2) B - Save the problem!
- Codeforces Round #437 (Div. 2, based on MemSQL Start[c]UP 3.0 - Round 2) E.Buy Low Sell High
- Codeforces Round #437 (Div. 2, based on MemSQL Start[c]UP 3.0 - Round 2) 题解
- Codeforces Round #437 (Div. 2, based on MemSQL Start[c]UP 3.0 - Round 2) 总结
- Codeforces Round #437 (Div. 2, based on MemSQL Start[c]UP 3.0 - Round 2) C.Ordering Pizza
- Codeforces Round #437 (Div. 2, based on MemSQL Start[c]UP 3.0 - Round 2)
- Codeforces Round #437 (Div. 2, based on MemSQL Start[c]UP 3.0 - Round 2) C - Ordering Pizza
- Codeforces Round #437 (Div. 2, based on MemSQL Start[c]UP 3.0 - Round 2)E - Buy Low Sell High
- Codeforces Round #437 (Div. 2, based on MemSQL Start[c]UP 3.0 - Round 2) E
- MemSQL Start[c]UP 3.0 - Round 2 and Codeforces Round #437 (Div. 1) D. Buy Low Sell High
- MemSQL Start[c]UP 3.0 - Round 2 and Codeforces Round #437 (Div. 1) B. Ordering Pizza
- 【MemSQL Start[c]UP 3.0 - Round 1 E】Desk Disorder
- MemSQL Start[c]UP 3.0 - Round 1 D. Third Month Insanity
- MemSQL Start[c]UP 3.0 - Round 1 E. Desk Disorder
- 【MemSQL Start[c]UP 3.0 - Round 1 C】 Pie Rules
- 【MemSQL Start[c]UP 3.0 - Round 1 B】 Lazy Security Guard
- 【MemSQL Start[c]UP 3.0 - Round 1 A】 Declined Finalists
- [Hash] Codeforces 452F MemSQL Start[c]UP 2.0 - Round 1 F. Permutation
- Codeforces Round #380 (Div. 2, Rated, Based on Technocup 2017 – Elimination Round 2) A. Interview wi