## Mock CCC '18 Contest 1 J2 - A Substring Problem

View as PDF

Points: 3 (partial)
Time limit: 2.0s
Memory limit: 1G

Problem type

A string is a palindrome if and only if it reads the same forwards and backwards.

A substring of a string is a nonempty sequence of consecutive characters from .

Define a string to be odd if and only if all substrings of the string that are palindromes have odd length.

Given a string , determine if it is odd.

#### Constraints

will only contain lowercase ASCII letters.

#### Input Specification

The input consists of a single line containing the string

#### Output Specification

Print on a single line, if the string is odd, Odd; if not, Even.

#### Sample Input 1

amanaplanacanalpanama

#### Sample Output 1

Odd

#### Sample Input 2

madamimadam

#### Sample Output 2

Odd

#### Sample Input 3

annamyfriend

#### Sample Output 3

Even

#### Sample Input 4

nopalindromes

#### Sample Output 4

Odd

• commented on Aug. 26, 2018, 10:48 p.m.

for some reason you need to end your answers with a newline to pass? it does say

Print on a single line, if the string...

so idk

• commented on Aug. 26, 2018, 11:29 p.m.

This happens to be a xiaowuc1 problem, which uses an identical checker. Standard convention uses a newline at the end of input, which is how the test data is formatted.

• commented on Feb. 15, 2018, 9:30 a.m.

To my younger students struggling with this question because you are attempting to check if every single substring is a palindrone, and then determining whether it has an even or odd length: I appreciate your tenacity.

There is a reason this is only a 3 point question and is considered "J2 level" as there is a simpler approach which may not be obvious to many of you. After fighting with this problem for a reasonable time, please click on the "Read editorial" link on the right, and read the message from the author for a hint.