zoukankan      html  css  js  c++  java
  • 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 }
  • 相关阅读:
    2020-10-24;我对机器学习实现的理解
    2020软件工程作业03
    友链
    导航页
    POJ3694 Network (板子题)
    洛谷 P1084 [NOIP2012 提高组] 疫情控制
    AcWing 355. 异象石
    洛谷P4556 雨天的尾巴
    POJ1639 Picnic Planning (K度限制最小生成树)
    POJ2728 Desert King
  • 原文地址:https://www.cnblogs.com/cszlg/p/2981163.html
Copyright © 2011-2022 走看看