链接
题解
不错的贪心题
先把 t w o n e twone twone的 o o o去掉
剩下的,只需要把 o n e one one的 n n n和 t w o two two的 w w w去掉就行了
代码
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define iinf 0x3f3f3f3f
#define linf (1ll<<60)
#define eps 1e-8
#define maxn 1000010
#define maxe 1000010
#define cl(x) memset(x,0,sizeof(x))
#define rep(_,__) for(_=1;_<=(__);_++)
#define em(x) emplace(x)
#define emb(x) emplace_back(x)
#define emf(x) emplace_front(x)
#define fi first
#define se second
#define de(x) cerr<<#x<<" = "<<x<<endl
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
ll read(ll x=0)
{
ll c, f(1);
for(c=getchar();!isdigit(c);c=getchar())if(c=='-')f=-f;
for(;isdigit(c);c=getchar())x=x*10+c-0x30;
return f*x;
}
ll T;
bool tag[maxn];
string s;
int main()
{
ios::sync_with_stdio(false);
ll i, n, j;
cin>>T;
while(T--)
{
cin>>s;
n=s.length();
vector<ll> ans;
for(i=0;i<n;i++)tag[i]=0;
for(i=0;i<=n-5;i++)
{
if(s.substr(i,5)=="twone")
{
ans.emb(i+2);
tag[i+1]=tag[i+3]=1;
}
}
for(i=0;i<=n-3;i++)
{
if( (s.substr(i,3)=="one" or s.substr(i,3)=="two") and !tag[i+1])ans.emb(i+1);
}
cout<<ans.size()<<'\n';
for(auto x:ans)cout<<x+1<<' ';
cout<<'\n';
}
return 0;
}