CF1155B.Game with Telephone Numbers

普及-

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

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

题目描述

A telephone number is a sequence of exactly 1111 digits such that its first digit is 8.

Vasya and Petya are playing a game. Initially they have a string ss of length nn (nn is odd) consisting of digits. Vasya makes the first move, then players alternate turns. In one move the player must choose a character and erase it from the current string. For example, if the current string 1121, after the player's move it may be 112, 111 or 121. The game ends when the length of string ss becomes 11. If the resulting string is a telephone number, Vasya wins, otherwise Petya wins.

You have to determine if Vasya has a winning strategy (that is, if Vasya can win the game no matter which characters Petya chooses during his moves).

电话号码是一个恰好由 1111 位数字组成的序列,且其首位数字为 8。

瓦西娅和佩佳正在玩一个游戏。初始时,他们有一个长度为 nn(nn 为奇数)的数字字符串 ss。瓦西娅先手,之后双方轮流进行操作。在每一轮中,当前玩家必须选择一个字符并将其从当前字符串中删除。例如,若当前字符串为 1121,则该玩家操作后,字符串可能变为 112、111 或 121。当字符串 ss 的长度变为 1111 时,游戏结束。若最终得到的字符串是一个电话号码,则瓦西娅获胜;否则佩佳获胜。

你需要判断瓦西娅是否存在必胜策略(即:无论佩佳在其回合中如何选择要删除的字符,瓦西娅都能获胜)。

输入格式

The first line contains one integer nn (13≤n<10513 \le n \lt 10^5, nn is odd) — the length of string ss.

The second line contains the string ss (∣s∣=n|s| = n) consisting only of decimal digits.

第一行包含一个整数 nn(13≤n<10513 \le n \lt 10^5,且 nn 为奇数)—— 字符串 ss 的长度。

第二行包含字符串 ss(∣s∣=n|s| = n),其仅由十进制数字组成。

输出格式

If Vasya has a strategy that guarantees him victory, print YES.

Otherwise print NO.

如果瓦西娅有确保获胜的策略,则输出 YES。
否则输出 NO。

输入输出样例

  • 输入#1

    13
    8380011223344

    输出#1

    YES
  • 输入#2

    15
    807345619350641

    输出#2

    NO

说明/提示

In the first example Vasya needs to erase the second character. Then Petya cannot erase a character from the remaining string 880011223344 so that it does not become a telephone number.

In the second example after Vasya's turn Petya can erase one character character 8. The resulting string can't be a telephone number, because there is no digit 8 at all.

在第一个例子中,瓦西娅需要擦除第二个字符。然后佩蒂娅无法从剩余的字符串 880011223344 中擦除任何字符,否则该字符串将不再是电话号码。

在第二个例子中,瓦西娅操作后,佩蒂娅可以擦除一个字符 8。得到的字符串不可能是电话号码,因为其中完全不存在数字 8。

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

首页