WC '17 Contest 1 J4 - Canuck Detection

View as PDF

Submit solution


Points: 5 (partial)
Time limit: 1.0s
Memory limit: 16M

Author:
Problem type
Woburn Challenge 2017-18 Round 1 - Junior Division

Nice, you've just landed your first software engineering internship at a popular blog site! Your first task is to collect data about which countries all of the site's bloggers live in, for further analysis.

Now, you don't exactly have the most experience with such things, but it's important that you get it done somehow. Asking for help would make you look weak! As a first step, it shouldn't be too hard to figure out whether or not a given user is Canadian, right?

You've already gotten a script together to load the text from a single blog post and strip it down into a more convenient format - a non-empty string S consisting of at most 50\,000 lowercase letters.

Unfortunately, from there, your algorithm is questionable at best. You know that a characteristic of words written by Canadians is that they sometimes end in our rather an or. However, due to faulty programming, your script will decide that the blogger is Canadian if their text contains at least one instance of the subsequence our.

A string subsequence is an ordered but possibly non-consecutive set of characters in it. For example, the string abac contains subsequences ab, ac, bc, and abc, among others. However, it does not contain the subsequence ca, as an a never appears anywhere after a c.

Things aren't looking great for your internship, but might as well at least test out your approach. Given a string S, output Y if your script would determine that the blogger is Canadian, or N otherwise.

Subtasks

In test cases worth 26/32 of the points, S contains at most 50 letters.

Input Specification

The first and only line of input consists of a single string, S.

Output Specification

Output a single character, either Y if the blogger is identified as a Canadian, or N otherwise.

Sample Input 1

colorusedtobemyfavoriteword

Sample Output 1

Y

Sample Input 2

torontousedtobemytowneh

Sample Output 2

N

Sample Explanation

In the first case, though the blogger doesn't seem very Canadian, the subsequence our is present at least once in S. One instance of it is indicated below:

col[o]r[u]sedtobemyfavoritewo[r]d

In the second case, though the blogger is clearly Canadian and S does contain the subsequence rou, it does not contain the subsequence our.


Comments


  • 0
    gavin_chen  commented on March 12, 2023, 7:50 p.m.

    someone explain to me why i am failing case 6 in batch 3?


    • 1
      Kirito  commented on March 13, 2023, 3:55 a.m.

      Your code is wrong; consider the input

      ruour

      If you want more debugging help, you are encouraged to join the DMOJ Discord.


      • 0
        gavin_chen  commented on March 13, 2023, 8:42 p.m.

        Oh thx, I was choosing the first instance of the characters.