Mock CCC '20 Contest 1 J3 - Lost Chocolate

View as PDF

Submit solution

Points: 3
Time limit: 2.0s
Memory limit: 256M

Author:
Problem type
Jonathan looking for his chocolate.

Luckily Unfortunately, Jonathan could not find anyone who could solve his puzzle. Instead, he decides that he will instead propose to the first person he sees by giving them a box of chocolates. While running across a grassy field to deliver this box of chocolates, he accidentally drops it somewhere in the field.

The field can be represented as a 2D grid with dimensions N by M where . represents an open area, J represents Jonathan's starting position and C represents the position of the dropped chocolates. Jonathan plans to find the chocolates by moving up one space then moving right one space and repeating these steps (up one, right one) until he exits the field. Will Jonathan be able to find his chocolates?

Input Specification

The first line of input contains two integers N and M (2 \le N,M \le 100).

The next N lines of input will contain M characters, consisting only of one J, one C and the rest ..

Output Specification

Output YES if Jonathan can find his chocolate or NO otherwise.

Sample Input 1

2 2
.C
J.

Sample Output 1

YES

Comments

There are no comments at the moment.