codeforces-scrape

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

955B.md (1408B)


      1 Source: https://codeforces.com/problemset/problem/955/B
      2 
      3 B. Not simply beatiful strings
      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 Let's call a string adorable if its letters can be realigned in such a way that they form two consequent groups of equal symbols (note that different groups must contain different symbols). For example, ababa is adorable (you can transform it to aaabb, where the first three letters form a group of *a*-s and others — a group of *b*-s), but cccc is not since in each possible consequent partition letters in these two groups coincide.
     22 
     23 You're given a string *s*. Check whether it can be split into two non-empty subsequences such that the strings formed by these subsequences are adorable. Here a subsequence is an arbitrary set of indexes of the string.
     24 
     25 Input
     26 
     27 The only line contains *s* (1 ≤ |*s*| ≤ 105) consisting of lowercase latin letters.
     28 
     29 Output
     30 
     31 Print «Yes» if the string can be split according to the criteria above or «No» otherwise.
     32 
     33 Each letter can be printed in arbitrary case.
     34 
     35 Examples
     36 
     37 Input
     38 
     39 ```
     40 ababa
     41 ```
     42 
     43 Output
     44 
     45 ```
     46 Yes
     47 ```
     48 
     49 Input
     50 
     51 ```
     52 zzcxx
     53 ```
     54 
     55 Output
     56 
     57 ```
     58 Yes
     59 ```
     60 
     61 Input
     62 
     63 ```
     64 yeee
     65 ```
     66 
     67 Output
     68 
     69 ```
     70 No
     71 ```
     72 
     73 Note
     74 
     75 In sample case two zzcxx can be split into subsequences zc and zxx each of which is adorable.
     76 
     77 There's no suitable partition in sample case three.