A12470 | Game with Telephone Numbers
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
A telephone number is a sequence of exactly $11$ digits such that its first digit is 8.
Vasya and Petya are playing a game. Initially they have a string $s$ of length $n$ ( $n$ 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 $s$ 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).
Vasya and Petya are playing a game. Initially they have a string $s$ of length $n$ ( $n$ 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 $s$ 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).
输入格式
The first line contains one integer $n$ ( $13 \le n < 10^5$ , $n$ is odd) — the length of string $s$ .
The second line contains the string $s$ ( $|s| = n$ ) consisting only of decimal digits.
The second line contains the string $s$ ( $|s| = n$ ) consisting only of decimal digits.
输出格式
If Vasya has a strategy that guarantees him victory, print YES.
Otherwise print NO.
Otherwise print 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.
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.
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted