As Simple as One and Two

E. As Simple as One and Two

You are given a non-empty string s = s 1 s 2 … s n s=s_1s_2\dots s_n s=s1s2sn, 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 s s if there is an integer j j j ( 1 ≤ j ≤ n − 2 1 \le j \le n-2 1jn2), that s j s j + 1 s j + 2 = s_{j}s_{j+1}s_{j+2}= sjsj+1sj+2=“one” or s j s j + 1 s j + 2 = s_{j}s_{j+1}s_{j+2}= 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 = s= s=“onetwone”, then if Polycarp selects two indices 3 3 3 and 6 6 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 t t ( 1 ≤ t ≤ 1 0 4 1 \le t \le 10^4 1t104) — the number of test cases in the input. Next, the test cases are given.

Each test case consists of one non-empty string s s s. Its length does not exceed 1.5 ⋅ 1 0 5 1.5\cdot10^5 1.5105. The string s s 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 ⋅ 1 0 6 1.5\cdot10^6 1.5106.

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 r r ( 0 ≤ r ≤ ∣ s ∣ 0 \le r \le |s| 0rs) — the required minimum number of positions to be removed, where ∣ s ∣ |s| s is the length of the given line. The second line of each answer should contain r r r different integers — the indices themselves for removal in any order. Indices are numbered from left to right from 1 1 1 to the length of the string. If r = 0 r=0 r=0, then the second line can be skipped (or you can print empty). If there are several answers, print any of them.

Example

Input

4
onetwone
testme
oneoneone
twotwo

Output

2
6 3
03
4 1 7 
2
1 4

Input

10
onetwonetwooneooonetwooo
two
one
twooooo
ttttwo
ttwwoo
ooone
onnne
oneeeee
oneeeeeeetwooooo

Output

6
18 11 12 1 6 21 
1
1 
1
3 
1
2 
1
6 
01
4 
01
1 
2
1 11 

Note

In the first example, answers are:

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

In the second example, answers are:

  • onetwonetwo****oneooonetwooo”,
  • two”,
  • one”,
  • twooooo”,
  • “ttttwo”,
  • “ttwwoo” — Polycarp likes it, there is nothing to remove,
  • “ooone”,
  • “onnne” — Polycarp likes it, there is nothing to remove,
  • oneeeee”,
  • oneeeeeeetwooooo”.

code

#include<bits/stdc++.h>
#define int long long
#define endl '\n'using namespace std;const int N = 2e5+10,INF=0x3f3f3f3f,mod=1e9+7;typedef pair<int,int> PII;int T=1;void solve(){string s;cin >> s;int n=s.length();vector<int> r;for(int i=0;i<n-2;i++){if(i<n-4) if(s.substr(i,5)=="twone") r.push_back(i+2),s[i+2]='9';if(s.substr(i,3)=="one" || s.substr(i,3)=="two") r.push_back(i+1);}cout<<r.size()<<"\n";for(auto x:r)cout<<x+1<<" ";cout<<"\n";
}signed main(){cin>>T; while(T--){solve();}return 0;
}

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/bicheng/59105.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

Spring Cloud Sleuth(Micrometer Tracing +Zipkin)

分布式链路追踪 分布式链路追踪技术要解决的问题&#xff0c;分布式链路追踪&#xff08;Distributed Tracing&#xff09;&#xff0c;就是将一次分布式请求还原成调用链路&#xff0c;进行日志记录&#xff0c;性能监控并将一次分布式请求的调用情况集中展示。比如各个服务节…

关于我的编程语言——C/C++——第四篇(深入1)

&#xff08;叠甲&#xff1a;如有侵权请联系&#xff0c;内容都是自己学习的总结&#xff0c;一定不全面&#xff0c;仅当互相交流&#xff08;轻点骂&#xff09;我也只是站在巨人肩膀上的一个小卡拉米&#xff0c;已老实&#xff0c;求放过&#xff09; 字符类型介绍 char…

一台手机可以登录运营多少个TikTok账号?

很多TikTok内容创作者和商家通过运营多个账号来实现品牌曝光和产品销售&#xff0c;这种矩阵运营方式需要一定的技巧和设备成本&#xff0c;那么对于很多新手来说&#xff0c;一台手机可以登录和运营多少个TikTok账号呢&#xff1f; 一、运营TikTok账号的数量限制 TikTok的官…

DNS服务器部署

一、要求 1.搭建dns服务器能够对自定义的正向或者反向域完成数据解析查询。 2.配置从DNS服务器&#xff0c;对主dns服务器进行数据备份。 二、配置 1.搭建dns服务器能够对自定义的正向或者反向域完成数据解析查询。 &#xff08;1&#xff09;首先需要安装bind服务 &#xf…

15分钟学 Go 第 34 天:依赖管理——Go Modules

第34天&#xff1a;依赖管理——Go Modules 目标&#xff1a;学习和掌握Go语言中的依赖管理工具“Go Modules”&#xff0c;理解如何使用Go Modules进行依赖管理。 一、Go Modules 简介 Go Modules 是 Go 语言官方推出的依赖管理工具&#xff0c;旨在解决 Go 语言项目中的依赖…

三周精通FastAPI:28 构建更大的应用 - 多个文件

官方文档&#xff1a;https://fastapi.tiangolo.com/zh/tutorial/bigger-applications 更大的应用 - 多个文件 如果你正在开发一个应用程序或 Web API&#xff0c;很少会将所有的内容都放在一个文件中。 FastAPI 提供了一个方便的工具&#xff0c;可以在保持所有灵活性的同时…

制作Ubuntu根文件系统

制作Ubuntu根文件系统&#xff1a; gunzip ubuntu-base-22.04.5-base-arm64.tar.gz mkdir ubuntu tar xvpf ubuntu-base-22.04.5-base-arm64.tar -C ubuntu 挂载目录、复制dns、执行chroot cd /userdisk/ubuntu cp /etc/resolv.conf ./etc/resolv.conf mount --bind /dev ./d…

Logstash 迁移索引元数据(设置和映射)

https://help.aliyun.com/zh/es/use-cases/use-logstash-to-migrate-full-or-incremental-data-from-self-managed-elasticsearch-to-alibaba-cloud-elasticsearch 在进行数据迁移时&#xff0c;Logstash会帮助您自动创建索引&#xff0c;但是自动创建的索引可能与您待迁移的索…

【Pandas】基础操作

&#x1f4dd;本文介绍 本文为作者观看pandas入门课后整理的基础操作笔记 &#x1f44b;作者简介&#xff1a;一个正在积极探索的本科生 &#x1f4f1;联系方式&#xff1a;943641266(QQ) &#x1f6aa;Github地址&#xff1a;https://github.com/sankexilianhua &#x1f511;…

【react使用AES对称加密的实现】

react使用AES对称加密的实现 前言使用CryptoJS库密钥存放加密方法解密方法结语 前言 项目中要求敏感信息怕被抓包泄密必须进行加密传输处理&#xff0c;普通的md5加密虽然能解决传输问题&#xff0c;但是项目中有权限的用户是需要查看数据进行查询的&#xff0c;所以就不能直接…

【STM32】INA3221三通道电压电流采集模块,HAL库

一、简单介绍 芯片的datasheet地址&#xff1a; INA3221 三通道、高侧测量、分流和总线电压监视器&#xff0c;具有兼容 I2C 和 SMBUS 的接口 datasheet (Rev. B) 笔者所使用的INA3221是淘宝买的模块 原理图 模块的三个通道的电压都是一样&#xff0c;都是POWER。这个芯片采用…

《机器人SLAM导航核心技术与实战》第1季:第10章_其他SLAM系统

视频讲解 【第1季】10.第10章_其他SLAM系统-视频讲解 【第1季】10.1.第10章_其他SLAM系统_RTABMAP算法-视频讲解 【第1季】10.2.第10章_其他SLAM系统_VINS算法-视频讲解 【第1季】10.3.第10章_其他SLAM系统_机器学习与SLAM-视频讲解 第1季&#xff1a;第10章_其他SLAM系统 …

《HelloGitHub》第 103 期

兴趣是最好的老师&#xff0c;HelloGitHub 让你对编程感兴趣&#xff01; 简介 HelloGitHub 分享 GitHub 上有趣、入门级的开源项目。 github.com/521xueweihan/HelloGitHub 这里有实战项目、入门教程、黑科技、开源书籍、大厂开源项目等&#xff0c;涵盖多种编程语言 Python、…

【OJ题解】C++实现反转字符串中的每个单词

&#x1f4b5;个人主页: 起名字真南 &#x1f4b5;个人专栏:【数据结构初阶】 【C语言】 【C】 【OJ题解】 题目要求&#xff1a;给定一个字符串 s &#xff0c;你需要反转字符串中每个单词的字符顺序&#xff0c;同时仍保留空格和单词的初始顺序。 题目链接: 反转字符串中的所…

Oracle OCP认证考试考点详解082系列09

题记&#xff1a; 本系列主要讲解Oracle OCP认证考试考点&#xff08;题目&#xff09;&#xff0c;适用于19C/21C,跟着学OCP考试必过。 41. 第41题&#xff1a; 题目 41.Examine the description of the EMPLOYEES table NLS_DATE_FORMAT is set to DD-MON-YY Which query…

创建线程时传递参数给线程

在C中&#xff0c;可以使用 std::thread 来创建和管理线程&#xff0c;同时可以通过几种方式将参数传递给线程函数。这些方法包括使用值传递、引用传递和指针传递。下面将对这些方法进行详细讲解并给出相应的代码示例。 1. 值传递参数 当你创建线程并希望传递参数时&#xff…

Linux下cgdb/gdb调试以及关于操作系统那些事

目录 一.gdb调试 1.1debug和release版本有什么区别? 1.2性能优化 1.3gdb的使用 1.4cgdb的安装 二.什么是硬件 三.冯诺依曼体系 四.操作系统(OS) 4.1理解操作系统 4.1.1操作系统是什么? 4.1.2为什么要有操作系统? 4.1.3 OS-银行 4.1.4OS如何管理 理解库文件和系…

Kafka相关知识点(上)

为什么要使用消息队列&#xff1f; 使用消息队列的主要目的主要记住这几个关键词:解耦、异步、削峰填谷。 解耦: 在一个复杂的系统中&#xff0c;不同的模块或服务之间可能需要相互依赖&#xff0c;如果直接使用函数调用或者 API 调用的方式&#xff0c;会造成模块之间的耦合…

ureport配置方法

1、项目启动后登录这个网址&#xff0c;ip和端口自己系统的 http://localhost:8080/ureport/designer 点击这个地方&#xff0c;图标类似一个文件夹选择下图标注的两个文件&#xff0c;这两个文件就是eoa系统要用到的报表文件&#xff0c;还是点击类似文件夹图标的图标 正在上…

在Linux上搭建Minecraft服务器的方法

前些天发现了一个巨牛的人工智能学习网站&#xff0c;通俗易懂&#xff0c;风趣幽默&#xff0c;忍不住分享一下给大家。点击跳转到网站。 在 Linux&#xff08;Ubuntu 12.04&#xff09;上设置 Minecraft 服务器是一个相当简单的任务&#xff0c;只需通过命令行即可完成。 在…