Description:
You are given a non-empty string s = s 1 s 2 … s n s=s1s2…sn s=s1s2…sn, which consists only of lowercase Latin letters. Polycarp does not like a string if it contains at least one string " o n e " "one" "one" or at least one string " t w o " "two" "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 ) j (1≤j≤n−2) j(1≤j≤n−2), that s s j + 1 s j + 2 = " o n e " ss_{j+1}s_{j+2}="one" ssj+1sj+2="one" or s j s j + 1 s j + 2 = " t w o " . s_{j}s_{j+1}s_{j+2}="two". sjsj+1sj+2="two".
For example:
Polycarp does not like strings
"
o
n
e
e
e
"
,
"
o
n
t
w
o
w
"
"oneee", "ontwow"
"oneee","ontwow",
"
t
w
o
n
e
"
"twone"
"twone" and
"
o
n
e
o
n
e
t
w
o
"
"oneonetwo"
"oneonetwo" (they all have at least one substring
"
o
n
e
"
"one"
"one" or
"
t
w
o
"
"two"
"two"),
Polycarp likes strings
"
o
o
n
n
e
e
"
"oonnee"
"oonnee",
t
w
w
w
o
"
twwwo"
twwwo" and
"
t
w
n
o
e
"
"twnoe"
"twnoe" (they have no substrings
"
o
n
e
"
"one"
"one" and
"
t
w
o
"
"two"
"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= " o n e t w o n e " "onetwone" "onetwone", then if Polycarp selects two indices 3 and 6, then “onetwone” will be selected and the result is " o n t w n e " . "ontwne". "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 ≤ 1 0 4 ) t (1≤t≤10^4) 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 ⋅ 1 0 5 1.5⋅10^5 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. 1.5⋅106. 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.
Examples
input
4
onetwone
testme
oneoneone
twotwo
output
2
6 3
0
3
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
0
1
4
0
1
1
2
1 11
Note
In the first example, answers are:
“onetwone”,
“testme” — Polycarp likes it, there is nothing to remove,
“oneoneone”,
“twotwo”.
**题意:**给出一串字符串,连续子串中不能包含 o n e , t w o one,two one,two求最少删除多少字符可以变得符合要求。根据题意模拟就行。
AC代码:
#include <cstdio>
#include <vector>
#include <queue>
#include <cstring>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <stack>
#include <queue>
using namespace std;
#define sd(n) scanf("%d", &n)
#define sdd(n, m) scanf("%d%d", &n, &m)
#define sddd(n, m, k) scanf("%d%d%d", &n, &m, &k)
#define pd(n) printf("%d\n", n)
#define pc(n) printf("%c", n)
#define pdd(n, m) printf("%d %d", n, m)
#define pld(n) printf("%lld\n", n)
#define pldd(n, m) printf("%lld %lld\n", n, m)
#define sld(n) scanf("%lld", &n)
#define sldd(n, m) scanf("%lld%lld", &n, &m)
#define slddd(n, m, k) scanf("%lld%lld%lld", &n, &m, &k)
#define sf(n) scanf("%lf", &n)
#define sc(n) scanf("%c", &n)
#define sff(n, m) scanf("%lf%lf", &n, &m)
#define sfff(n, m, k) scanf("%lf%lf%lf", &n, &m, &k)
#define ss(str) scanf("%s", str)
#define rep(i, a, n) for (int i = a; i <= n; i++)
#define per(i, a, n) for (int i = n; i >= a; i--)
#define mem(a, n) memset(a, n, sizeof(a))
#define debug(x) cout << #x << ": " << x << endl
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define fi first
#define se second
#define mod(x) ((x) % MOD)
#define gcd(a, b) __gcd(a, b)
#define lowbit(x) (x & -x)
typedef pair<int, int> PII;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const int MOD = 1e9 + 7;
const double eps = 1e-9;
const ll INF = 0x3f3f3f3f3f3f3f3fll;
const int inf = 0x3f3f3f3f;
inline int read()
{
int ret = 0, sgn = 1;
char ch = getchar();
while (ch < '0' || ch > '9')
{
if (ch == '-')
sgn = -1;
ch = getchar();
}
while (ch >= '0' && ch <= '9')
{
ret = ret * 10 + ch - '0';
ch = getchar();
}
return ret * sgn;
}
inline void Out(int a)
{
if (a > 9)
Out(a / 10);
putchar(a % 10 + '0');
}
ll gcd(ll a, ll b)
{
return b == 0 ? a : gcd(b, a % b);
}
ll lcm(ll a, ll b)
{
return a * b / gcd(a, b);
}
///快速幂m^k%mod
ll qpow(int m, int k, int mod)
{
ll res = 1, t = m;
while (k)
{
if (k & 1)
res = res * t % mod;
t = t * t % mod;
k >>= 1;
}
return res;
}
// 快速幂求逆元
int Fermat(int a, int p) //费马求a关于b的逆元
{
return qpow(a, p - 2, p);
}
///扩展欧几里得
int exgcd(int a, int b, int &x, int &y)
{
if (b == 0)
{
x = 1;
y = 0;
return a;
}
int g = exgcd(b, a % b, x, y);
int t = x;
x = y;
y = t - a / b * y;
return g;
}
///使用ecgcd求a的逆元x
int mod_reverse(int a, int p)
{
int d, x, y;
d = exgcd(a, p, x, y);
if (d == 1)
return (x % p + p) % p;
else
return -1;
}
///中国剩余定理模板
ll china(int a[], int b[], int n) //a[]为除数,b[]为余数
{
int M = 1, y, x = 0;
for (int i = 0; i < n; ++i) //算出它们累乘的结果
M *= a[i];
for (int i = 0; i < n; ++i)
{
int w = M / a[i];
int tx = 0;
int t = exgcd(w, a[i], tx, y); //计算逆元
x = (x + w * (b[i] / t) * x) % M;
}
return (x + M) % M;
}
int n, t, x;
int res, cnt, temp;
vector<int> ans;
string s;
int main()
{
sd(t);
while (t--)
{
cin >> s;
int len = s.length();
ans.clear();
int i = 0;
while (i < len - 2)
{
if (s[i] != 't' && s[i] != 'o')
{
i++;
continue;
}
if (i < len - 5 && s.substr(i, 6) == "twoone")
{
ans.push_back(i + 2);
ans.push_back(i + 5);
i = i + 6;
}
else if (i < len - 4 && s.substr(i, 5) == "twone")
{
ans.push_back(i + 3);
i = i + 5;
}
else if (s.substr(i, 3) == "two")
{
ans.push_back(i + 2);
i += 3;
}
else if (s.substr(i, 3) == "one")
{
ans.push_back(i + 2);
i += 3;
}
else
i++;
}
res = ans.size();
pd(res);
if (res == 0)
cout << endl;
else
{
for (auto i : ans)
{
cout << i << " ";
}
cout << endl;
}
}
return 0;
}