CF849A.Odds and Ends

入门

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

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

题目描述

Where do odds begin, and where do they end? Where does hope emerge, and will they ever break?

Given an integer sequence _a_1, _a_2, ..., a__n of length n. Decide whether it is possible to divide it into an odd number of non-empty subsegments, the each of which has an odd length and begins and ends with odd numbers.

A subsegment is a contiguous slice of the whole sequence. For example, {3, 4, 5} and {1} are subsegments of sequence {1, 2, 3, 4, 5, 6}, while {1, 2, 4} and {7} are not.

奇数从何开始,又在何处终结?希望于何时萌生,它们是否终将破灭?

给定一个长度为 nn 的整数序列 a1, a2, ..., ana_1, a_2, ..., a_n。请判断能否将其划分为奇数个非空子段,使得每个子段长度为奇数,且每个子段的首尾元素均为奇数。

子段(subsegment)是指整个序列的一个连续片段。例如,{3, 4, 5}\{3, 4, 5\} 和 {1}\{1\} 是序列 {1, 2, 3, 4, 5, 6}\{1, 2, 3, 4, 5, 6\} 的子段,而 {1, 2, 4}\{1, 2, 4\} 和 {7}\{7\} 则不是。

输入格式

The first line of input contains a non-negative integer n (1 ≤ n ≤ 100) — the length of the sequence.

The second line contains n space-separated non-negative integers _a_1, _a_2, ..., a__n (0 ≤ a__i ≤ 100) — the elements of the sequence.

输入的第一行包含一个非负整数 nn(1 ≤ n ≤ 1001 \leq n \leq 100)—— 表示序列的长度。

第二行包含 nn 个用空格分隔的非负整数 a1, a2, ..., ana_1,\,a_2,\,...,\,a_n(0 ≤ ai ≤ 1000 \leq a_i \leq 100)—— 表示序列的元素。

输出格式

Output "Yes" if it's possible to fulfill the requirements, and "No" otherwise.

You can output each letter in any case (upper or lower).

如果可以满足要求,则输出“Yes”;否则输出“No”。

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

输入输出样例

  • 输入#1

    3
    1 3 5

    输出#1

    Yes
  • 输入#2

    5
    1 0 1 5 1

    输出#2

    Yes
  • 输入#3

    3
    4 3 1

    输出#3

    No
  • 输入#4

    4
    3 9 9 3

    输出#4

    No

说明/提示

In the first example, divide the sequence into 1 subsegment: {1, 3, 5} and the requirements will be met.

In the second example, divide the sequence into 3 subsegments: {1, 0, 1}, {5}, {1}.

In the third example, one of the subsegments must start with 4 which is an even number, thus the requirements cannot be met.

In the fourth example, the sequence can be divided into 2 subsegments: {3, 9, 9}, {3}, but this is not a valid solution because 2 is an even number.

在第一个例子中,将序列划分为 1 个子段:{1, 3, 5},即可满足要求。

在第二个例子中,将序列划分为 3 个子段:{1, 0, 1}、{5}、{1}。

在第三个例子中,某个子段必须以 4(一个偶数)开头,因此无法满足要求。

在第四个例子中,序列可被划分为 2 个子段:{3, 9, 9}、{3},但这不是有效解,因为 2 是一个偶数。

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

首页