CF982A.Row

普及-

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

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

题目描述

You're given a row with nn chairs. We call a seating of people "maximal" if the two following conditions hold:

  1. There are no neighbors adjacent to anyone seated.
  2. It's impossible to seat one more person without violating the first rule.

The seating is given as a string consisting of zeros and ones (00 means that the corresponding seat is empty, 11 — occupied). The goal is to determine whether this seating is "maximal".

Note that the first and last seats are not adjacent (if n≠2n \ne 2).

给你一排 nn 把椅子。我们称一种就座方式为“极大”的,当且仅当满足以下两个条件:

  1. 任意就座者均不与他人相邻;
  2. 无法再安排任何一人入座而不违反第一条规则。

给定的就座情况用一个由 0 和 1 组成的字符串表示(0 表示对应座位为空,1 表示已被占用)。你的任务是判断该就座方式是否为“极大”的。

注意:首尾座位不视为相邻(当 n≠2n \ne 2 时)。

输入格式

The first line contains a single integer nn (1≤n≤10001 \leq n \leq 1000) — the number of chairs.

The next line contains a string of nn characters, each of them is either zero or one, describing the seating.

第一行包含一个整数 nn(1≤n≤10001 \leq n \leq 1000)——椅子的数量。

下一行包含一个长度为 nn 的字符串,其中每个字符为 0 或 1,用于描述座位安排。

输出格式

Output "Yes" (without quotation marks) if the seating is "maximal". Otherwise print "No".

You are allowed to print letters in whatever case you'd like (uppercase or lowercase).

如果座位安排是“最大化的”,则输出“Yes”(不带引号);否则输出“No”。

您可以按任意大小写形式输出字母(大写或小写)。

输入输出样例

  • 输入#1

    3
    101

    输出#1

    Yes
  • 输入#2

    4
    1011

    输出#2

    No
  • 输入#3

    5
    10001

    输出#3

    No

说明/提示

In sample case one the given seating is maximal.

In sample case two the person at chair three has a neighbour to the right.

In sample case three it is possible to seat yet another person into chair three.

在样例一中,给定的就座安排是最大化的。

在样例二中,坐在三号椅子上的人右侧有邻座。

在样例三中,还可以在三号椅子上再安排一个人就座。

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

首页