HomeVolumesContestsSectionsForumsUsersPrintHelpAbout

Contests > IMPC - 2013-2014 > problem:


14-04-40. 50712 - Moon algebra

IMPC - 2013-2014

Start: Mar.16.2013 at 12:00:00 PM
Finish: Mar.16.2013 at 05:00:00 PM
The contest is finished!
• Contest scoreboard

Guest
• Review clarifications (1)

Contest problems

• 14-03-40. 50773 - Balanced Sum Tree
• 14-03-60. 50382 - Parkside's Other ...
• 14-03-70. 50468 - Draw Matrix - 2
• 14-03-70. 50468 - Draw Matrix - 2
• 14-03-80. 50675 - Kruja Boys
• 14-03-90. 50717 - Hurdle Jumping
• 14-04-20. 50493 - n-digit kth Prime ...
• 14-04-30. 50669 - Area of an Irregu...
• 14-04-40. 50712 - Moon algebra
• 14-04-50. 50697 - Base Stations
• 14-05-10. 50723 - Tribonacci
• 14-05-20. 50677 - The Cottage
• 14-05-20. 50413 - Valid Permutations
• 14-05-30. 50688 - Epoka Furgon
• 14-05-30. 50706 - The most crowd...
• 14-05-40. 50689 - The biggest build...
• 14-05-50. 50414 - Traffic

Feedback

If you notice incorrect translations in Contester, please let author know.

Time limit 2000/4000/4000/4000 ms. Memory limit 65000/65000/65000/65000 Kb.
Question by Ilir Capuni.

Moon algebra

We are given the set {a, b, c} on which we define the following binary operations:

  a * a = b     a * b = b     a * c = a  
  b * a = c     b * b = b     b * c = a  
  c * a = a     c * b = c     c * c = c  

Question: We are given an expression containing N terms from the above set and * between each. Check if it is possible to place () such that the result of the expression evaluates to a.

Input specification
An integer denoting N on the first line and the expression on the second where 1 ≤ N ≤ 10.

Output specification
Print "Yes" or "No", if there is a way.
(No, resp., there is no way) to place the () such that the expression evaluates to a.

 Sample Input I  
 4
 a * c * c * b
 Sample Input II  
 3
 a * b * b
 Sample Input III  
 4
 c * b * a * c
 Sample Output I  
 Yes
 Sample Output II  
 No
 Sample Output III  
 Yes
 Explanation I   
 (a*c)*(c*b)=a*c=a
 Explanation II   
 (a * b) * b = b, a*(b*b) = b
 Explanation III   
 (c*b)*(a*c)


Для отправки решений необходимо выполнить вход.

www.contester.ru