Tuesday 12 November 2013

Regionals 2006 :: Africa/Middle East - Arab and North Africa. Being Smarty! (UVALive 3755)

Problem: Being Smarty!
You are given two integer (R and N) and two string in a single line. you have to separate the integers and strings.  a string made of upper- or lower-case letters, digits, and/or spaces. A string may be surrounded by double quotes,  If a property contains spaces, the surrounding double quotes are mandatory. first N row contains 1st string, 2nd N rows contains 2nd string, 3rd N rows contains 1st row and so on.
You have to print string of Rth row. if there is any upper case character in that string, print that character in lower case.

Category: Adhoc, IO handling.

Idea: first take the integers, then remove extra spaces, if 1st character of the 1st string is ", then insert the remaining string until another " found to 1st string. do the same for 2nd string. if there is no ", task is easier for you.
you can determine which string you have to print by the following condition.
((r-1)/n)%2, if 0, 1st string, otherwise 2nd stirng

code:


No comments:

Post a Comment