codeforces-scrape

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

1276A.md (3043B)


      1 Source: https://codeforces.com/problemset/problem/1276/A
      2 
      3 A. As Simple as One and Two
      4 
      5 time limit per test
      6 
      7 3 seconds
      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 You are given a non-empty string $s=s_1s_2\dots s_n$, which consists only of lowercase Latin letters. Polycarp does not like a string if it contains at least one string "one" or at least one string "two" (or both at the same time) as a substring. In other words, Polycarp does not like the string $s$ if there is an integer $j$ ($1 \le j \le n-2$), that $s_{j}s_{j+1}s_{j+2}=$"one" or $s_{j}s_{j+1}s_{j+2}=$"two".
     22 
     23 For example:
     24 
     25 * Polycarp does not like strings "oneee", "ontwow", "twone" and "oneonetwo" (they all have at least one substring "one" or "two"),
     26 * Polycarp likes strings "oonnee", "twwwo" and "twnoe" (they have no substrings "one" and "two").
     27 
     28 Polycarp wants to select a certain set of indices (positions) and remove all letters on these positions. All removals are made at the same time.
     29 
     30 For example, if the string looks like $s=$"onetwone", then if Polycarp selects two indices $3$ and $6$, then "onetwone" will be selected and the result is "ontwne".
     31 
     32 What is the minimum number of indices (positions) that Polycarp needs to select to make the string liked? What should these positions be?
     33 
     34 Input
     35 
     36 The first line of the input contains an integer $t$ ($1 \le t \le 10^4$) — the number of test cases in the input. Next, the test cases are given.
     37 
     38 Each test case consists of one non-empty string $s$. Its length does not exceed $1.5\cdot10^5$. The string $s$ consists only of lowercase Latin letters.
     39 
     40 It is guaranteed that the sum of lengths of all lines for all input data in the test does not exceed $1.5\cdot10^6$.
     41 
     42 Output
     43 
     44 Print an answer for each test case in the input in order of their appearance.
     45 
     46 The first line of each answer should contain $r$ ($0 \le r \le |s|$) — the required minimum number of positions to be removed, where $|s|$ is the length of the given line. The second line of each answer should contain $r$ different integers — the indices themselves for removal in any order. Indices are numbered from left to right from $1$ to the length of the string. If $r=0$, then the second line can be skipped (or you can print empty). If there are several answers, print any of them.
     47 
     48 Examples
     49 
     50 Input
     51 
     52 ```
     53 4
     54 onetwone
     55 testme
     56 oneoneone
     57 twotwo
     58 ```
     59 
     60 Output
     61 
     62 ```
     63 2
     64 6 3
     65 0
     66 
     67 3
     68 4 1 7 
     69 2
     70 1 4
     71 ```
     72 
     73 Input
     74 
     75 ```
     76 10
     77 onetwonetwooneooonetwooo
     78 two
     79 one
     80 twooooo
     81 ttttwo
     82 ttwwoo
     83 ooone
     84 onnne
     85 oneeeee
     86 oneeeeeeetwooooo
     87 ```
     88 
     89 Output
     90 
     91 ```
     92 6
     93 18 11 12 1 6 21 
     94 1
     95 1 
     96 1
     97 3 
     98 1
     99 2 
    100 1
    101 6 
    102 0
    103 
    104 1
    105 4 
    106 0
    107 
    108 1
    109 1 
    110 2
    111 1 11
    112 ```
    113 
    114 Note
    115 
    116 In the first example, answers are:
    117 
    118 * "onetwone",
    119 * "testme" — Polycarp likes it, there is nothing to remove,
    120 * "oneoneone",
    121 * "twotwo".
    122 
    123 In the second example, answers are:
    124 
    125 * "onetwonetwooneooonetwooo",
    126 * "two",
    127 * "one",
    128 * "twooooo",
    129 * "ttttwo",
    130 * "ttwwoo" — Polycarp likes it, there is nothing to remove,
    131 * "ooone",
    132 * "onnne" — Polycarp likes it, there is nothing to remove,
    133 * "oneeeee",
    134 * "oneeeeeeetwooooo".