A. Anton and Danik

Codeforces
IDCF734A
Time1000ms
Memory256MB
Difficulty
implementationstrings
English · Original
Chinese · Translation
Formal · Original
Anton likes to play chess, and so does his friend Danik. Once they have played _n_ games in a row. For each game it's known who was the winner — Anton or Danik. None of the games ended with a tie. Now Anton wonders, who won more games, he or Danik? Help him determine this. ## Input The first line of the input contains a single integer _n_ (1 ≤ _n_ ≤ 100 000) — the number of games played. The second line contains a string _s_, consisting of _n_ uppercase English letters '_A_' and '_D_' — the outcome of each of the games. The _i_\-th character of the string is equal to '_A_' if the Anton won the _i_\-th game and '_D_' if Danik won the _i_\-th game. ## Output If Anton won more games than Danik, print "_Anton_" (without quotes) in the only line of the output. If Danik won more games than Anton, print "_Danik_" (without quotes) in the only line of the output. If Anton and Danik won the same number of games, print "_Friendship_" (without quotes). [samples] ## Note In the first sample, Anton won 6 games, while Danik — only 1. Hence, the answer is "_Anton_". In the second sample, Anton won 3 games and Danik won 4 games, so the answer is "_Danik_". In the third sample, both Anton and Danik won 3 games and the answer is "_Friendship_".
Anton 喜欢下棋,他的朋友 Danik 也喜欢。 他们连续进行了 #cf_span[n] 场游戏。每场比赛都有胜负(非平局),已知每场的胜者是 Anton 还是 Danik。 现在 Anton 想知道,他和 Danik 谁赢的场次更多?请帮助他确定。 输入的第一行包含一个整数 #cf_span[n] (#cf_span[1 ≤ n ≤ 100 000]) —— 表示进行的游戏场数。 第二行包含一个长度为 #cf_span[n] 的字符串 #cf_span[s],由大写英文字母 '_A_' 和 '_D_' 组成,表示每场比赛的结果。字符串的第 #cf_span[i] 个字符为 '_A_' 表示 Anton 赢了第 #cf_span[i] 场比赛,为 '_D_' 表示 Danik 赢了第 #cf_span[i] 场比赛。 如果 Anton 赢的场次多于 Danik,请在输出的唯一一行中打印 "_Anton_"(不含引号)。 如果 Danik 赢的场次多于 Anton,请在输出的唯一一行中打印 "_Danik_"(不含引号)。 如果 Anton 和 Danik 赢的场次相同,请打印 "_Friendship_"(不含引号)。 在第一个样例中,Anton 赢了 #cf_span[6] 场,而 Danik 只赢了 #cf_span[1] 场,因此答案是 "_Anton_"。 在第二个样例中,Anton 赢了 #cf_span[3] 场,Danik 赢了 #cf_span[4] 场,因此答案是 "_Danik_"。 在第三个样例中,Anton 和 Danik 都赢了 #cf_span[3] 场,因此答案是 "_Friendship_"。 ## Input 输入的第一行包含一个整数 #cf_span[n] (#cf_span[1 ≤ n ≤ 100 000]) —— 表示进行的游戏场数。第二行包含一个长度为 #cf_span[n] 的字符串 #cf_span[s],由大写英文字母 '_A_' 和 '_D_' 组成,表示每场比赛的结果。字符串的第 #cf_span[i] 个字符为 '_A_' 表示 Anton 赢了第 #cf_span[i] 场比赛,为 '_D_' 表示 Danik 赢了第 #cf_span[i] 场比赛。 ## Output 如果 Anton 赢的场次多于 Danik,请在输出的唯一一行中打印 "_Anton_"(不含引号)。如果 Danik 赢的场次多于 Anton,请在输出的唯一一行中打印 "_Danik_"(不含引号)。如果 Anton 和 Danik 赢的场次相同,请打印 "_Friendship_"(不含引号)。 [samples] ## Note 在第一个样例中,Anton 赢了 #cf_span[6] 场,而 Danik 只赢了 #cf_span[1] 场,因此答案是 "_Anton_"。在第二个样例中,Anton 赢了 #cf_span[3] 场,Danik 赢了 #cf_span[4] 场,因此答案是 "_Danik_"。在第三个样例中,Anton 和 Danik 都赢了 #cf_span[3] 场,因此答案是 "_Friendship_"。
**Definitions** Let $ n \in \mathbb{Z} $ be the number of games, with $ 1 \leq n \leq 100{,}000 $. Let $ s \in \{A, D\}^n $ be a string representing the outcomes of the games, where $ s_i = A $ if Anton won the $ i $-th game, and $ s_i = D $ if Danik won the $ i $-th game. **Constraints** $ 1 \leq n \leq 100{,}000 $, and $ s_i \in \{A, D\} $ for all $ i \in \{1, \dots, n\} $. **Objective** Let $ a = |\{i \mid s_i = A\}| $ and $ d = |\{i \mid s_i = D\}| $. Output: - $ \text{Anton} $ if $ a > d $, - $ \text{Danik} $ if $ d > a $, - $ \text{Friendship} $ if $ a = d $.
Samples
Input #1
6
ADAAAA
Output #1
Anton
Input #2
7
DDDAADA
Output #2
Danik
Input #3
6
DADADA
Output #3
Friendship
API Response (JSON)
{
  "problem": {
    "name": "A. Anton and Danik",
    "description": {
      "content": "Anton likes to play chess, and so does his friend Danik. Once they have played _n_ games in a row. For each game it's known who was the winner — Anton or Danik. None of the games ended with a tie. N",
      "description_type": "Markdown"
    },
    "platform": "Codeforces",
    "limit": {
      "time_limit": 1000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "CF734A"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "Anton likes to play chess, and so does his friend Danik.\n\nOnce they have played _n_ games in a row. For each game it's known who was the winner — Anton or Danik. None of the games ended with a tie.\n\nN...",
      "is_translate": false,
      "language": "English"
    },
    {
      "statement_type": "Markdown",
      "content": "Anton 喜欢下棋,他的朋友 Danik 也喜欢。\n\n他们连续进行了 #cf_span[n] 场游戏。每场比赛都有胜负(非平局),已知每场的胜者是 Anton 还是 Danik。\n\n现在 Anton 想知道,他和 Danik 谁赢的场次更多?请帮助他确定。\n\n输入的第一行包含一个整数 #cf_span[n] (#cf_span[1 ≤ n ≤ 100 000]) —— 表示进行的游戏场数。\n\n第...",
      "is_translate": true,
      "language": "Chinese"
    },
    {
      "statement_type": "Markdown",
      "content": "**Definitions**  \nLet $ n \\in \\mathbb{Z} $ be the number of games, with $ 1 \\leq n \\leq 100{,}000 $.  \nLet $ s \\in \\{A, D\\}^n $ be a string representing the outcomes of the games, where $ s_i = A $ if...",
      "is_translate": false,
      "language": "Formal"
    }
  ]
}
Full JSON Raw Segments