博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
【CodeForces 1277C --- As Simple as One and Two】
阅读量:2038 次
发布时间:2019-04-28

本文共 2661 字,大约阅读时间需要 8 分钟。

【CodeForces 1277C --- As Simple as One and Two】

题目来源:

Description

You are given a non-empty string s=s1s2…sn, 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≤j≤n−2), that sjsj+1sj+2=“one” or sjsj+1sj+2=“two”.

For example:

  • Polycarp does not like strings “oneee”, “ontwow”, “twone” and “oneonetwo” (they all have at least one substring “one” or “two”),
  • Polycarp likes strings “oonnee”, “twwwo” and “twnoe” (they have no substrings “one” and “two”).

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.

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”.

What is the minimum number of indices (positions) that Polycarp needs to select to make the string liked? What should these positions be?

Input

The first line of the input contains an integer t (1≤t≤104) — the number of test cases in the input. Next, the test cases are given.

Each test case consists of one non-empty string s. Its length does not exceed 1.5⋅105. The string s consists only of lowercase Latin letters.

It is guaranteed that the sum of lengths of all lines for all input data in the test does not exceed 1.5⋅106.

Output

Print an answer for each test case in the input in order of their appearance.

The first line of each answer should contain r (0≤r≤|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.

Sample Input

4

onetwone
testme
oneoneone
twotwo

Sample Output

2

6 3
0

3

4 1 7
2
1 4

Note

In the first example, answers are:

“onetwone”,

“testme” — Polycarp likes it, there is nothing to remove,
“oneoneone”,
“twotwo”.

AC代码:

#include 
using namespace std;#define SIS std::ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)#define endl '\n'using ll = long long;int main(){
SIS; int T; cin >> T; while(T--) {
string s; cin >> s; s='#' + s; int len=s.size(); vector
v; vector
vis(len,false); for(int i=1;i

转载地址:http://zpyof.baihongyu.com/

你可能感兴趣的文章
google app api相关(商用)
查看>>
linux放音乐cd
查看>>
GridView+存储过程实现'真分页'
查看>>
flask_migrate
查看>>
Spring的BeanUtils的copyProperties方法需要注意的点
查看>>
方法回调/钩子
查看>>
Java中常用缓存Cache机制的实现
查看>>
数据库设计规范化的 5 个要求
查看>>
手动启动 oracle 服务
查看>>
二 垃圾回收:第06讲:深入剖析:垃圾回收你真的了解吗?(下)
查看>>
ObjectMapper 的一些坑
查看>>
spring 几种获得bean的方法
查看>>
Server returns invalid timezone. Go to ‘Advanced‘ tab and set ‘serverTimezon‘
查看>>
SQL查询语句执行顺序详解
查看>>
如何避免创建不必要的对象
查看>>
老司机入职一周,给我们解读 Spring Boot 最流行的 16 条实践
查看>>
maven删除不必要的依赖;优化pom依赖研究
查看>>
2017 年你不能错过的 Java 类库
查看>>
Java笔记——面向切面编程(AOP模式)
查看>>
javaweb学习总结——获得MySQL数据库自动生成的主键
查看>>