Codeforces Round #174 (Div. 2) B. Cows and Poker Game(简单)

B. Cows and Poker Game
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

There are n cows playing poker at a table. For the current betting phase, each player's status is either "ALLIN", "IN", or "FOLDED", and does not change throughout the phase. To increase the suspense, a player whose current status is not "FOLDED" may show his/her hand to the table. However, so as not to affect any betting decisions, he/she may only do so if all other players have a status of either "ALLIN" or "FOLDED". The player's own status may be either "ALLIN" or "IN".

Find the number of cows that can currently show their hands without affecting any betting decisions.

Input

The first line contains a single integer, n (2 ≤ n ≤ 2·105). The second line contains n characters, each either "A", "I", or "F". The i-th character is "A" if the i-th player's status is "ALLIN", "I" if the i-th player's status is "IN", or "F" if the i-th player's status is "FOLDED".

Output

The first line should contain a single integer denoting the number of players that can currently show their hands.

Sample test(s)
Input
6
AFFAAA
Output
4
Input
3
AFI
Output
1
Note

In the first sample, cows 1, 4, 5, and 6 can show their hands. In the second sample, only cow 3 can show her hand.

AC Code:

 1 #include <iostream>
 2 #include <fstream>
 3 #include <string>
 4 #include <set>
 5 #include <map>
 6 #include <vector>
 7 #include <stack>
 8 #include <queue>
 9 #include <cmath>
10 #include <cstdio>
11 #include <cstring>
12 #include <algorithm>
13 #include <utility>
14 using namespace std;
15 #define ll long long
16 #define cti const int
17 #define ctll const long long
18 #define dg(i) cout << '*' << i << endl;
19 
20 int n, in, fo, al, ans;
21 char a[200005];
22 
23 int main()
24 {
25     while(cin >> n)
26     {
27         ans = al = fo = in = 0;
28         scanf("%s", a);
29         for(int i = 0; i < n; i++)
30         {
31             if(a[i] == 'F') fo++;
32             else if(a[i] == 'A') al++;
33             else in++;
34         }
35         if(al && !in) ans += al;
36         else if(in == 1) ans++;
37         printf("%d\n", ans);
38     }
39     return 0;
40 }

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值