codeforces-scrape

Codeforces scraped problems and editorials
git clone git://git.laack.co/codeforces-scrape.git
Log | Files | Refs | README

957A.md (2143B)


      1 Source: https://codeforces.com/problemset/problem/957/A
      2 
      3 A. Tritonic Iridescence
      4 
      5 time limit per test
      6 
      7 1 second
      8 
      9 memory limit per test
     10 
     11 256 megabytes
     12 
     13 input
     14 
     15 standard input
     16 
     17 output
     18 
     19 standard output
     20 
     21 Overlooking the captivating blend of myriads of vernal hues, Arkady the painter lays out a long, long canvas.
     22 
     23 Arkady has a sufficiently large amount of paint of three colours: cyan, magenta, and yellow. On the one-dimensional canvas split into *n* consecutive segments, each segment needs to be painted in one of the colours.
     24 
     25 Arkady has already painted some (possibly none or all) segments and passes the paintbrush to you. You are to determine whether there are at least two ways of colouring all the unpainted segments so that no two adjacent segments are of the same colour. Two ways are considered different if and only if a segment is painted in different colours in them.
     26 
     27 Input
     28 
     29 The first line contains a single positive integer *n* (1 ≤ *n* ≤ 100) — the length of the canvas.
     30 
     31 The second line contains a string *s* of *n* characters, the *i*-th of which is either 'C' (denoting a segment painted in cyan), 'M' (denoting one painted in magenta), 'Y' (one painted in yellow), or '?' (an unpainted one).
     32 
     33 Output
     34 
     35 If there are at least two different ways of painting, output "Yes"; otherwise output "No" (both without quotes).
     36 
     37 You can print each character in any case (upper or lower).
     38 
     39 Examples
     40 
     41 Input
     42 
     43 ```
     44 5  
     45 CY??Y
     46 ```
     47 
     48 Output
     49 
     50 ```
     51 Yes
     52 ```
     53 
     54 Input
     55 
     56 ```
     57 5  
     58 C?C?Y
     59 ```
     60 
     61 Output
     62 
     63 ```
     64 Yes
     65 ```
     66 
     67 Input
     68 
     69 ```
     70 5  
     71 ?CYC?
     72 ```
     73 
     74 Output
     75 
     76 ```
     77 Yes
     78 ```
     79 
     80 Input
     81 
     82 ```
     83 5  
     84 C??MM
     85 ```
     86 
     87 Output
     88 
     89 ```
     90 No
     91 ```
     92 
     93 Input
     94 
     95 ```
     96 3  
     97 MMY
     98 ```
     99 
    100 Output
    101 
    102 ```
    103 No
    104 ```
    105 
    106 Note
    107 
    108 For the first example, there are exactly two different ways of colouring: CYCMY and CYMCY.
    109 
    110 For the second example, there are also exactly two different ways of colouring: CMCMY and CYCMY.
    111 
    112 For the third example, there are four ways of colouring: MCYCM, MCYCY, YCYCM, and YCYCY.
    113 
    114 For the fourth example, no matter how the unpainted segments are coloured, the existing magenta segments will prevent the painting from satisfying the requirements. The similar is true for the fifth example.