description stringlengths 171 4k | code stringlengths 94 3.98k | normalized_code stringlengths 57 4.99k |
|---|---|---|
You are given a non-empty string s=s_1s_2... 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 β€ j β€ n-2), that s_{j}s_{j+1}s_{j+2}="one" or s_{j}s_{j+1}s_{j+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 β€ 10^4) β 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β
10^5. 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β
10^6.
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".
In the second example, answers are:
* "onetwonetwooneooonetwooo",
* "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". | t = int(input())
for _ in range(t):
s = input()
a = s.count("one")
b = s.count("two")
c = s.count("twone")
if a + b == 0:
print(0)
print(" ")
else:
count = a + b - c
i = 0
ans = []
while i < len(s) - 2:
if s[i : i + 5] == "twone":
ans.append(str(i + 3))
i += 5
elif s[i : i + 3] == "one" or s[i : i + 3] == "two":
ans.append(str(i + 2))
i += 3
else:
i += 1
print(count)
print(" ".join(ans)) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING IF BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR STRING ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR LIST WHILE VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER IF VAR VAR BIN_OP VAR NUMBER STRING VAR VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL STRING VAR |
You are given a non-empty string s=s_1s_2... 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 β€ j β€ n-2), that s_{j}s_{j+1}s_{j+2}="one" or s_{j}s_{j+1}s_{j+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 β€ 10^4) β 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β
10^5. 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β
10^6.
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".
In the second example, answers are:
* "onetwonetwooneooonetwooo",
* "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". | from sys import stdin
a = lambda: stdin.readline()
for _ in range(int(a())):
s = [*a()]
n = len(s) - 1
result, res, i = 0, [], 0
app = res.append
while i < n - 2:
x = "".join(s[i : i + 3])
if x == "one":
result += 1
app(i + 2)
elif x == "two":
if i != n - 3:
if s[i + 3] == "o":
app(i + 2)
else:
s[i + 2] = "x"
app(i + 3)
result += 1
else:
result += 1
app(i + 3)
else:
i = i
i += 1
print(result)
print(*res) | ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FUNC_CALL VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR VAR NUMBER LIST NUMBER ASSIGN VAR VAR WHILE VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL STRING VAR VAR BIN_OP VAR NUMBER IF VAR STRING VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR STRING IF VAR BIN_OP VAR NUMBER IF VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR |
You are given a non-empty string s=s_1s_2... 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 β€ j β€ n-2), that s_{j}s_{j+1}s_{j+2}="one" or s_{j}s_{j+1}s_{j+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 β€ 10^4) β 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β
10^5. 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β
10^6.
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".
In the second example, answers are:
* "onetwonetwooneooonetwooo",
* "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". | for _ in range(int(input())):
s = input()
j = 0
c = 0
l = []
if "one" in s or "two" in s:
while j < len(s):
if s[j : j + 5] == "twone":
l.append(j + 3)
j += 5
c += 1
elif s[j : j + 3] == "two":
l.append(j + 2)
j += 3
c += 1
elif s[j : j + 3] == "one":
l.append(j + 2)
j += 3
c += 1
else:
j += 1
print(c)
print(*l)
else:
print(0)
print("") | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST IF STRING VAR STRING VAR WHILE VAR FUNC_CALL VAR VAR IF VAR VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER VAR NUMBER IF VAR VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER VAR NUMBER IF VAR VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR STRING |
You are given a non-empty string s=s_1s_2... 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 β€ j β€ n-2), that s_{j}s_{j+1}s_{j+2}="one" or s_{j}s_{j+1}s_{j+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 β€ 10^4) β 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β
10^5. 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β
10^6.
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".
In the second example, answers are:
* "onetwonetwooneooonetwooo",
* "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". | for i in range(int(input())):
ans = []
s = input().replace("twone", "tw?ne").replace("one", "o?e").replace("two", "t?o")
for ind, c in enumerate(s):
if c == "?":
ans.append(ind + 1)
print(len(ans))
print(*ans) | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR FUNC_CALL FUNC_CALL FUNC_CALL FUNC_CALL VAR STRING STRING STRING STRING STRING STRING FOR VAR VAR FUNC_CALL VAR VAR IF VAR STRING EXPR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR |
You are given a non-empty string s=s_1s_2... 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 β€ j β€ n-2), that s_{j}s_{j+1}s_{j+2}="one" or s_{j}s_{j+1}s_{j+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 β€ 10^4) β 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β
10^5. 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β
10^6.
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".
In the second example, answers are:
* "onetwonetwooneooonetwooo",
* "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". | t = int(input().strip())
for _ in range(t):
s = input().strip()
l = len(s)
count = 0
ps = []
for i, c in enumerate(s):
if i == 0 or i == l - 1:
continue
elif c == "n" and s[i - 1 : i + 2] == "one":
if s[i - 3 : i + 2] != "twone":
ps.append(str(i + 1))
count += 1
elif c == "w" and s[i - 1 : i + 2] == "two":
if s[i - 1 : i + 4] != "twone":
ps.append(str(i + 1))
count += 1
else:
ps.append(str(i + 2))
count += 1
print(count)
print(" ".join(ps)) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR VAR FUNC_CALL VAR VAR IF VAR NUMBER VAR BIN_OP VAR NUMBER IF VAR STRING VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER STRING IF VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER IF VAR STRING VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER STRING IF VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL STRING VAR |
You are given a non-empty string s=s_1s_2... 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 β€ j β€ n-2), that s_{j}s_{j+1}s_{j+2}="one" or s_{j}s_{j+1}s_{j+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 β€ 10^4) β 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β
10^5. 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β
10^6.
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".
In the second example, answers are:
* "onetwonetwooneooonetwooo",
* "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". | for _ in range(int(input())):
s = input()
l = len(s)
x = 0
y = []
i = 0
while i < l - 2:
if s[i : i + 5] == "twone":
x += 1
y.append(i + 3)
i += 5
elif s[i : i + 3] == "one" or s[i : i + 3] == "two":
x += 1
y.append(i + 2)
i += 3
continue
else:
i += 1
continue
print(x)
if y != []:
print(" ".join(str(z) for z in y))
else:
print("") | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR NUMBER WHILE VAR BIN_OP VAR NUMBER IF VAR VAR BIN_OP VAR NUMBER STRING VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER IF VAR VAR BIN_OP VAR NUMBER STRING VAR VAR BIN_OP VAR NUMBER STRING VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR IF VAR LIST EXPR FUNC_CALL VAR FUNC_CALL STRING FUNC_CALL VAR VAR VAR VAR EXPR FUNC_CALL VAR STRING |
You are given a non-empty string s=s_1s_2... 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 β€ j β€ n-2), that s_{j}s_{j+1}s_{j+2}="one" or s_{j}s_{j+1}s_{j+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 β€ 10^4) β 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β
10^5. 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β
10^6.
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".
In the second example, answers are:
* "onetwonetwooneooonetwooo",
* "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". | MOD = 1000000007
ii = lambda: int(input())
si = lambda: input()
dgl = lambda: list(map(int, input()))
f = lambda: map(int, input().split())
il = lambda: list(map(int, input().split()))
ls = lambda: list(input())
for _ in range(ii()):
s = ls()
x = len(s)
sind = set()
for i in range(2, x - 2):
temp = s[i - 2] + s[i - 1] + s[i] + s[i + 1] + s[i + 2]
if temp == "twone":
s[i] = "-"
sind.add(i + 1)
for i in range(1, x - 1):
temp = s[i - 1] + s[i] + s[i + 1]
if temp in ["two", "one"]:
sind.add(i + 1)
print(len(sind))
print(*list(sind)) | ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP BIN_OP VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER VAR VAR VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER IF VAR STRING ASSIGN VAR VAR STRING EXPR FUNC_CALL VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER VAR VAR VAR BIN_OP VAR NUMBER IF VAR LIST STRING STRING EXPR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR |
You are given a non-empty string s=s_1s_2... 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 β€ j β€ n-2), that s_{j}s_{j+1}s_{j+2}="one" or s_{j}s_{j+1}s_{j+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 β€ 10^4) β 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β
10^5. 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β
10^6.
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".
In the second example, answers are:
* "onetwonetwooneooonetwooo",
* "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". | t = int(input())
for _ in range(t):
s = list(input())
n = len(s)
ans = []
for i in range(n - 4):
sub = "".join(s[i : i + 5])
if sub == "twone":
s[i + 2] = "%"
ans.append(i + 3)
for i in range(n - 2):
sub = "".join(s[i : i + 3])
if sub == "one" or sub == "two":
s[i + 1] = "%"
ans.append(i + 2)
print(len(ans))
print(" ".join(map(str, ans))) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL STRING VAR VAR BIN_OP VAR NUMBER IF VAR STRING ASSIGN VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL STRING VAR VAR BIN_OP VAR NUMBER IF VAR STRING VAR STRING ASSIGN VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL STRING FUNC_CALL VAR VAR VAR |
You are given a non-empty string s=s_1s_2... 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 β€ j β€ n-2), that s_{j}s_{j+1}s_{j+2}="one" or s_{j}s_{j+1}s_{j+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 β€ 10^4) β 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β
10^5. 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β
10^6.
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".
In the second example, answers are:
* "onetwonetwooneooonetwooo",
* "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". | import sys
for _ in range(int(input())):
s = sys.stdin.readline()
to_eliminate = []
r = 0
lens = 0
rs = ""
for x in s:
lens += 1
if lens >= 3 and x == "o" and s[lens - 2] == "w" and s[lens - 3] == "t":
to_eliminate += [lens - 1]
r += 1
if x == "e" and lens >= 3 and s[lens - 2] == "n" and s[lens - 3] == "o":
if lens >= 5 and s[lens - 4] == "w" and s[lens - 5] == "t":
to_eliminate.pop()
to_eliminate += [lens - 2]
else:
to_eliminate += [lens - 1]
r += 1
print(r)
print(*to_eliminate) | IMPORT FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR STRING FOR VAR VAR VAR NUMBER IF VAR NUMBER VAR STRING VAR BIN_OP VAR NUMBER STRING VAR BIN_OP VAR NUMBER STRING VAR LIST BIN_OP VAR NUMBER VAR NUMBER IF VAR STRING VAR NUMBER VAR BIN_OP VAR NUMBER STRING VAR BIN_OP VAR NUMBER STRING IF VAR NUMBER VAR BIN_OP VAR NUMBER STRING VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR VAR LIST BIN_OP VAR NUMBER VAR LIST BIN_OP VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR |
You are given a non-empty string s=s_1s_2... 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 β€ j β€ n-2), that s_{j}s_{j+1}s_{j+2}="one" or s_{j}s_{j+1}s_{j+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 β€ 10^4) β 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β
10^5. 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β
10^6.
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".
In the second example, answers are:
* "onetwonetwooneooonetwooo",
* "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". | for _ in range(int(input())):
s = input()
i = 0
req = 0
ans = []
while i < len(s):
if s[i : i + 5] == "twone":
req += 1
ans.append(i + 2)
i += 5
elif s[i : i + 3] == "one" or s[i : i + 3] == "two":
req += 1
ans.append(i + 1)
i += 3
else:
i += 1
print(req)
for a in ans:
print(a + 1, end=" ")
print() | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST WHILE VAR FUNC_CALL VAR VAR IF VAR VAR BIN_OP VAR NUMBER STRING VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER IF VAR VAR BIN_OP VAR NUMBER STRING VAR VAR BIN_OP VAR NUMBER STRING VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR FOR VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR |
You are given a non-empty string s=s_1s_2... 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 β€ j β€ n-2), that s_{j}s_{j+1}s_{j+2}="one" or s_{j}s_{j+1}s_{j+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 β€ 10^4) β 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β
10^5. 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β
10^6.
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".
In the second example, answers are:
* "onetwonetwooneooonetwooo",
* "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". | t = int(input())
for _ in range(t):
s = input()
l = len(s)
res = 0
arr = []
i = 0
while i < l:
if i < l - 4 and s[i : i + 5] == "twone":
arr.append(i + 3)
i += 5
elif i < l - 2:
if s[i : i + 3] == "two":
arr.append(i + 2)
i += 3
elif s[i : i + 3] == "one":
arr.append(i + 2)
i += 3
else:
i += 1
else:
i += 1
print(len(arr))
print(*arr) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR NUMBER WHILE VAR VAR IF VAR BIN_OP VAR NUMBER VAR VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER IF VAR BIN_OP VAR NUMBER IF VAR VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER IF VAR VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR |
You are given a non-empty string s=s_1s_2... 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 β€ j β€ n-2), that s_{j}s_{j+1}s_{j+2}="one" or s_{j}s_{j+1}s_{j+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 β€ 10^4) β 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β
10^5. 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β
10^6.
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".
In the second example, answers are:
* "onetwonetwooneooonetwooo",
* "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". | for _ in range(int(input())):
s = input().replace("twone", "tw_ne").replace("one", "o_e").replace("two", "t_o")
A = {i for i, ch in enumerate(s, 1) if ch == "_"}
print(len(A))
print(*A) | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL FUNC_CALL FUNC_CALL VAR STRING STRING STRING STRING STRING STRING ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR NUMBER VAR STRING EXPR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR |
You are given a non-empty string s=s_1s_2... 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 β€ j β€ n-2), that s_{j}s_{j+1}s_{j+2}="one" or s_{j}s_{j+1}s_{j+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 β€ 10^4) β 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β
10^5. 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β
10^6.
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".
In the second example, answers are:
* "onetwonetwooneooonetwooo",
* "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". | for _ in range(int(input())):
s = input()
ans = []
for i in range(len(s)):
if 2 <= i <= len(s) - 2 and s[i - 2 : i + 3] == "twone":
ans.append(i + 1)
elif i >= 2 and s[i - 2 : i + 1] == "two":
ans.append(i)
elif i <= len(s) - 2 and s[i : i + 3] == "one":
ans.append(i + 2)
print(len(ans))
print(*ans) | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF NUMBER VAR BIN_OP FUNC_CALL VAR VAR NUMBER VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR NUMBER VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR VAR IF VAR BIN_OP FUNC_CALL VAR VAR NUMBER VAR VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR |
You are given a non-empty string s=s_1s_2... 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 β€ j β€ n-2), that s_{j}s_{j+1}s_{j+2}="one" or s_{j}s_{j+1}s_{j+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 β€ 10^4) β 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β
10^5. 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β
10^6.
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".
In the second example, answers are:
* "onetwonetwooneooonetwooo",
* "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". | I = input
for _ in range(int(I())):
s = list(I())
ind = []
i = 0
n = len(s)
while i < n:
if i + 2 < n and (
s[i] == "o"
and s[i + 1] == "n"
and s[i + 2] == "e"
or s[i] == "t"
and s[i + 1] == "w"
and s[i + 2] == "o"
):
if i + 4 < n and s[i + 2] == "o" and s[i + 3] == "n" and s[i + 4] == "e":
ind.append(i + 2 + 1)
i += 4
else:
ind.append(i + 1 + 1)
i += 2
i += 1
print(len(ind))
for i in ind:
print(i, end=" ")
print() | ASSIGN VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR WHILE VAR VAR IF BIN_OP VAR NUMBER VAR VAR VAR STRING VAR BIN_OP VAR NUMBER STRING VAR BIN_OP VAR NUMBER STRING VAR VAR STRING VAR BIN_OP VAR NUMBER STRING VAR BIN_OP VAR NUMBER STRING IF BIN_OP VAR NUMBER VAR VAR BIN_OP VAR NUMBER STRING VAR BIN_OP VAR NUMBER STRING VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER NUMBER VAR NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER NUMBER VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR FOR VAR VAR EXPR FUNC_CALL VAR VAR STRING EXPR FUNC_CALL VAR |
You are given a non-empty string s=s_1s_2... 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 β€ j β€ n-2), that s_{j}s_{j+1}s_{j+2}="one" or s_{j}s_{j+1}s_{j+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 β€ 10^4) β 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β
10^5. 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β
10^6.
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".
In the second example, answers are:
* "onetwonetwooneooonetwooo",
* "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". | t = int(input())
for _ in range(0, t):
s = input()
n = len(s)
ans = []
i = 0
sto = "twone"
so = "one"
st = "two"
while i < n - 2:
if i + 5 <= n and s[i : i + 5] == sto:
ans.append(i + 3)
i += 5
elif s[i : i + 3] == so:
ans.append(i + 2)
i += 3
elif s[i : i + 3] == st:
ans.append(i + 2)
i += 3
else:
i += 1
print(len(ans))
print(*ans) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR STRING ASSIGN VAR STRING ASSIGN VAR STRING WHILE VAR BIN_OP VAR NUMBER IF BIN_OP VAR NUMBER VAR VAR VAR BIN_OP VAR NUMBER VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER IF VAR VAR BIN_OP VAR NUMBER VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER IF VAR VAR BIN_OP VAR NUMBER VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR |
You are given a non-empty string s=s_1s_2... 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 β€ j β€ n-2), that s_{j}s_{j+1}s_{j+2}="one" or s_{j}s_{j+1}s_{j+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 β€ 10^4) β 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β
10^5. 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β
10^6.
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".
In the second example, answers are:
* "onetwonetwooneooonetwooo",
* "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". | t = int(input())
l2 = []
for i in range(t):
s = input()
k = list(s)
c = 0
l1 = []
c1 = 0
while c1 < len(k) - 2:
if s[c1 : c1 + 3] == "one":
l1.append(c1 + 2)
c1 += 3
c += 1
elif s[c1 : c1 + 3] == "two":
if s[c1 + 2 : c1 + 5] == "one":
l1.append(c1 + 3)
c1 += 5
c += 1
else:
l1.append(c1 + 2)
c1 += 3
c += 1
else:
c1 += 1
pass
l1.append(c)
l2.append(l1)
for k in range(t):
print(l2[k][len(l2[k]) - 1])
for i in range(len(l2[k]) - 1):
print(l2[k][i], end=" ")
print() | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR NUMBER WHILE VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER VAR NUMBER IF VAR VAR BIN_OP VAR NUMBER STRING IF VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR BIN_OP FUNC_CALL VAR VAR VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR VAR VAR STRING EXPR FUNC_CALL VAR |
You are given a non-empty string s=s_1s_2... 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 β€ j β€ n-2), that s_{j}s_{j+1}s_{j+2}="one" or s_{j}s_{j+1}s_{j+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 β€ 10^4) β 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β
10^5. 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β
10^6.
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".
In the second example, answers are:
* "onetwonetwooneooonetwooo",
* "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". | import sys
readline = sys.stdin.readline
ns = lambda: readline().rstrip()
ni = lambda: int(readline().rstrip())
nm = lambda: map(int, readline().split())
nl = lambda: list(map(int, readline().split()))
for _ in range(ni()):
s = ns()
ind = []
i = 0
while i < len(s) - 2:
if s[i] == "o":
if s[i + 1] == "n" and s[i + 2] == "e":
ind.append(i + 1)
i += 2
elif s[i] == "t":
if (
i < len(s) - 4
and s[i + 1] == "w"
and s[i + 2] == "o"
and s[i + 3] == "n"
and s[i + 4] == "e"
):
ind.append(i + 2)
i += 4
elif s[i + 1] == "w" and s[i + 2] == "o":
ind.append(i + 1)
i += 2
i += 1
print(len(ind))
for i in ind:
print(i + 1, end=" ")
print() | IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER WHILE VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR VAR STRING IF VAR BIN_OP VAR NUMBER STRING VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER IF VAR VAR STRING IF VAR BIN_OP FUNC_CALL VAR VAR NUMBER VAR BIN_OP VAR NUMBER STRING VAR BIN_OP VAR NUMBER STRING VAR BIN_OP VAR NUMBER STRING VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER IF VAR BIN_OP VAR NUMBER STRING VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR FOR VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR |
You are given a non-empty string s=s_1s_2... 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 β€ j β€ n-2), that s_{j}s_{j+1}s_{j+2}="one" or s_{j}s_{j+1}s_{j+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 β€ 10^4) β 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β
10^5. 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β
10^6.
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".
In the second example, answers are:
* "onetwonetwooneooonetwooo",
* "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". | from sys import stdin, stdout
input = stdin.readline
t = int(input())
for _ in range(t):
s = input()[:-1]
n = len(s)
ans = []
i = 1
while 1:
i += 1
if i >= n:
break
if (
s[i] == "o"
and s[i - 1] == "w"
and s[i - 2] == "t"
and i + 1 < n
and s[i + 1] == "n"
and i + 2 < n
and s[i + 2] == "e"
):
ans.append(i + 1)
i = i + 3
elif s[i] == "o" and s[i - 1] == "w" and s[i - 2] == "t":
ans.append(i)
i += 1
elif s[i] == "e" and s[i - 1] == "n" and s[i - 2] == "o":
ans.append(i)
i += 1
print(len(ans))
print(*ans) | ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST ASSIGN VAR NUMBER WHILE NUMBER VAR NUMBER IF VAR VAR IF VAR VAR STRING VAR BIN_OP VAR NUMBER STRING VAR BIN_OP VAR NUMBER STRING BIN_OP VAR NUMBER VAR VAR BIN_OP VAR NUMBER STRING BIN_OP VAR NUMBER VAR VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF VAR VAR STRING VAR BIN_OP VAR NUMBER STRING VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR VAR VAR NUMBER IF VAR VAR STRING VAR BIN_OP VAR NUMBER STRING VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR VAR VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR |
You are given a non-empty string s=s_1s_2... 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 β€ j β€ n-2), that s_{j}s_{j+1}s_{j+2}="one" or s_{j}s_{j+1}s_{j+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 β€ 10^4) β 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β
10^5. 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β
10^6.
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".
In the second example, answers are:
* "onetwonetwooneooonetwooo",
* "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". | for _ in range(int(input())):
l = list(input())
n = len(l)
cnt = []
for i in range(n - 2):
if i + 5 <= n:
if l[i : i + 5] == list("twone"):
l[i + 2] = " "
cnt.append(i + 3)
continue
if l[i : i + 3] == list("one"):
l[i + 1] = " "
cnt.append(i + 2)
if l[i : i + 3] == list("two"):
l[i + 1] = " "
cnt.append(i + 2)
print(len(cnt))
print(*cnt) | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF BIN_OP VAR NUMBER VAR IF VAR VAR BIN_OP VAR NUMBER FUNC_CALL VAR STRING ASSIGN VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR VAR BIN_OP VAR NUMBER FUNC_CALL VAR STRING ASSIGN VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR VAR BIN_OP VAR NUMBER FUNC_CALL VAR STRING ASSIGN VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR |
You are given a non-empty string s=s_1s_2... 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 β€ j β€ n-2), that s_{j}s_{j+1}s_{j+2}="one" or s_{j}s_{j+1}s_{j+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 β€ 10^4) β 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β
10^5. 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β
10^6.
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".
In the second example, answers are:
* "onetwonetwooneooonetwooo",
* "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". | T = int(input(""))
for v in range(T):
a = input("")
n = len(a)
p = []
t = []
for i in range(n - 2):
if a[i : i + 3] == "one":
p.append(i)
if a[i : i + 3] == "two":
p.append(i)
if len(p) == 0:
print(0)
continue
ans = 0
i = 0
fin = []
while i < len(p) - 1:
if p[i + 1] != p[i] + 2:
fin.append(p[i] + 2)
ans = ans + 1
i += 1
else:
fin.append(p[i] + 3)
ans = ans + 1
i += 2
if len(p) > 1:
if p[-1] != p[-2] + 2:
fin.append(p[-1] + 2)
ans = ans + 1
else:
ans = ans + 1
fin.append(p[0] + 2)
print(ans)
if ans != 0:
for h in fin:
print(h, end=" ")
print("")
else:
print("") | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR STRING FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR VAR IF VAR VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST WHILE VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR BIN_OP VAR NUMBER BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER VAR NUMBER IF FUNC_CALL VAR VAR NUMBER IF VAR NUMBER BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR VAR IF VAR NUMBER FOR VAR VAR EXPR FUNC_CALL VAR VAR STRING EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING |
You are given a non-empty string s=s_1s_2... 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 β€ j β€ n-2), that s_{j}s_{j+1}s_{j+2}="one" or s_{j}s_{j+1}s_{j+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 β€ 10^4) β 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β
10^5. 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β
10^6.
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".
In the second example, answers are:
* "onetwonetwooneooonetwooo",
* "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". | rr = lambda: input().strip()
rri = lambda: int(rr())
rrm = lambda: [int(x) for x in rr().split()]
def sol():
s = input()
n = len(s)
if n < 3:
print(0)
print()
return 0
if n > 4:
res = 0
ind = []
i = 0
while i < n - 4:
if s[i] + s[i + 1] + s[i + 2] == "two":
res += 1
if s[i + 3] + s[i + 4] == "ne":
ind.append(str(i + 2 + 1))
i += 5
else:
ind.append(str(i + 1 + 1))
i += 3
elif s[i] + s[i + 1] + s[i + 2] == "one":
res += 1
ind.append(str(i + 1 + 1))
i += 3
else:
i += 1
while i < n - 2:
if (
s[i] + s[i + 1] + s[i + 2] == "one"
or s[i] + s[i + 1] + s[i + 2] == "two"
):
res += 1
ind.append(str(i + 1 + 1))
i += 3
else:
i += 1
print(res)
if res > 0:
inds = " ".join(ind)
print(inds)
else:
print()
return 0
i = 0
res = 0
ind = []
while i < n - 2:
if s[i] + s[i + 1] + s[i + 2] == "one" or s[i] + s[i + 1] + s[i + 2] == "two":
res += 1
ind.append(str(i + 1 + 1))
i += 3
else:
i += 1
print(res)
if res > 0:
inds = " ".join(ind)
print(inds)
else:
print()
return 0
T = rri()
for _ in range(T):
ans = sol() | ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR RETURN NUMBER IF VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR NUMBER WHILE VAR BIN_OP VAR NUMBER IF BIN_OP BIN_OP VAR VAR VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER STRING VAR NUMBER IF BIN_OP VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER NUMBER VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER NUMBER VAR NUMBER IF BIN_OP BIN_OP VAR VAR VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER STRING VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER NUMBER VAR NUMBER VAR NUMBER WHILE VAR BIN_OP VAR NUMBER IF BIN_OP BIN_OP VAR VAR VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER STRING BIN_OP BIN_OP VAR VAR VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER STRING VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER NUMBER VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR IF VAR NUMBER ASSIGN VAR FUNC_CALL STRING VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR RETURN NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST WHILE VAR BIN_OP VAR NUMBER IF BIN_OP BIN_OP VAR VAR VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER STRING BIN_OP BIN_OP VAR VAR VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER STRING VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER NUMBER VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR IF VAR NUMBER ASSIGN VAR FUNC_CALL STRING VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR RETURN NUMBER ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR |
You are given a non-empty string s=s_1s_2... 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 β€ j β€ n-2), that s_{j}s_{j+1}s_{j+2}="one" or s_{j}s_{j+1}s_{j+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 β€ 10^4) β 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β
10^5. 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β
10^6.
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".
In the second example, answers are:
* "onetwonetwooneooonetwooo",
* "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". | t = int(input())
Ans = ""
for p in range(t):
s = input()
l = len(s)
i = 0
ans = 0
ind = ""
while i < len(s) - 2:
if i + 4 < len(s) and s[i : i + 5] == "twone":
ind += str(i + 3) + " "
ans += 1
i += 5
elif i + 2 < len(s) and s[i : i + 3] == "one":
ind += str(i + 2) + " "
ans += 1
i += 3
elif i + 2 < len(s) and s[i : i + 3] == "two":
ind += str(i + 2) + " "
ans += 1
i += 3
else:
i += 1
Ans += str(ans) + "\n" + ind + "\n"
print(Ans) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR STRING FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR STRING WHILE VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF BIN_OP VAR NUMBER FUNC_CALL VAR VAR VAR VAR BIN_OP VAR NUMBER STRING VAR BIN_OP FUNC_CALL VAR BIN_OP VAR NUMBER STRING VAR NUMBER VAR NUMBER IF BIN_OP VAR NUMBER FUNC_CALL VAR VAR VAR VAR BIN_OP VAR NUMBER STRING VAR BIN_OP FUNC_CALL VAR BIN_OP VAR NUMBER STRING VAR NUMBER VAR NUMBER IF BIN_OP VAR NUMBER FUNC_CALL VAR VAR VAR VAR BIN_OP VAR NUMBER STRING VAR BIN_OP FUNC_CALL VAR BIN_OP VAR NUMBER STRING VAR NUMBER VAR NUMBER VAR NUMBER VAR BIN_OP BIN_OP BIN_OP FUNC_CALL VAR VAR STRING VAR STRING EXPR FUNC_CALL VAR VAR |
You are given a non-empty string s=s_1s_2... 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 β€ j β€ n-2), that s_{j}s_{j+1}s_{j+2}="one" or s_{j}s_{j+1}s_{j+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 β€ 10^4) β 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β
10^5. 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β
10^6.
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".
In the second example, answers are:
* "onetwonetwooneooonetwooo",
* "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". | t = int(input())
for _ in range(t):
ind = []
s = list(input())
l = len(s)
for i in range(2, l):
if i + 2 < l:
if (
s[i - 2] == "t"
and s[i - 1] == "w"
and s[i] == "o"
and s[i + 1] == "n"
and s[i + 2] == "e"
):
ind.append(i + 1)
s[i] = ""
if s[i - 2] == "o" and s[i - 1] == "n" and s[i] == "e":
ind.append(i)
s[i - 1] = ""
elif s[i - 2] == "t" and s[i - 1] == "w" and s[i] == "o":
ind.append(i)
s[i - 1] = ""
elif s[i - 2] == "o" and s[i - 1] == "n" and s[i] == "e":
ind.append(i)
s[i - 1] = ""
elif s[i - 2] == "t" and s[i - 1] == "w" and s[i] == "o":
ind.append(i)
s[i - 1] = ""
print(len(ind))
print(*ind) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER VAR IF BIN_OP VAR NUMBER VAR IF VAR BIN_OP VAR NUMBER STRING VAR BIN_OP VAR NUMBER STRING VAR VAR STRING VAR BIN_OP VAR NUMBER STRING VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR VAR STRING IF VAR BIN_OP VAR NUMBER STRING VAR BIN_OP VAR NUMBER STRING VAR VAR STRING EXPR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR NUMBER STRING IF VAR BIN_OP VAR NUMBER STRING VAR BIN_OP VAR NUMBER STRING VAR VAR STRING EXPR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR NUMBER STRING IF VAR BIN_OP VAR NUMBER STRING VAR BIN_OP VAR NUMBER STRING VAR VAR STRING EXPR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR NUMBER STRING IF VAR BIN_OP VAR NUMBER STRING VAR BIN_OP VAR NUMBER STRING VAR VAR STRING EXPR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR |
You are given a non-empty string s=s_1s_2... 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 β€ j β€ n-2), that s_{j}s_{j+1}s_{j+2}="one" or s_{j}s_{j+1}s_{j+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 β€ 10^4) β 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β
10^5. 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β
10^6.
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".
In the second example, answers are:
* "onetwonetwooneooonetwooo",
* "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". | import sys
input = sys.stdin.readline
t = int(input())
for testcaess in range(t):
S = input().strip() + "zzzzzzzz"
LEN = len(S)
ANS = [0] * LEN
for i in range(LEN):
if S[i : i + 3] == "two":
if S[i + 2 : i + 5] == "one":
ANS[i + 2] = 1
else:
ANS[i + 1] = 1
for i in range(LEN):
if S[i : i + 3] == "one":
if ANS[i] == 1:
continue
else:
ANS[i + 1] = 1
A = []
for i in range(LEN):
if ANS[i] == 1:
A.append(i + 1)
print(len(A))
print(*A) | IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR BIN_OP VAR NUMBER STRING IF VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER STRING ASSIGN VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR BIN_OP VAR NUMBER STRING IF VAR VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR |
You are given a non-empty string s=s_1s_2... 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 β€ j β€ n-2), that s_{j}s_{j+1}s_{j+2}="one" or s_{j}s_{j+1}s_{j+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 β€ 10^4) β 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β
10^5. 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β
10^6.
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".
In the second example, answers are:
* "onetwonetwooneooonetwooo",
* "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". | for _ in range(int(input())):
s = input()
ans = []
i = 0
while i < len(s):
one = False
twone = False
two = False
if i + 3 <= len(s):
if s[i : i + 3] == "two":
two = True
if i + 5 <= len(s) and s[i + 3 : i + 5] == "ne":
twone = True
if s[i : i + 3] == "one":
one = True
if two:
if twone:
ans.append(i + 2 + 1)
i += 5
else:
ans.append(i + 1 + 1)
i += 3
elif one:
ans.append(i + 1 + 1)
i += 3
else:
i += 1
print(len(ans))
print(*ans) | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER WHILE VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF BIN_OP VAR NUMBER FUNC_CALL VAR VAR IF VAR VAR BIN_OP VAR NUMBER STRING ASSIGN VAR NUMBER IF BIN_OP VAR NUMBER FUNC_CALL VAR VAR VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER STRING ASSIGN VAR NUMBER IF VAR VAR BIN_OP VAR NUMBER STRING ASSIGN VAR NUMBER IF VAR IF VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER NUMBER VAR NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER NUMBER VAR NUMBER IF VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER NUMBER VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR |
You are given a non-empty string s=s_1s_2... 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 β€ j β€ n-2), that s_{j}s_{j+1}s_{j+2}="one" or s_{j}s_{j+1}s_{j+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 β€ 10^4) β 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β
10^5. 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β
10^6.
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".
In the second example, answers are:
* "onetwonetwooneooonetwooo",
* "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". | for i in range(int(input())):
q = set()
s = input() + "?????"
for i in range(len(s)):
if s[i] == "t":
if s[i : i + 5] == "twone":
q.add(i + 3)
s = s.replace("twone", "?????")
for i in range(len(s)):
if s[i] == "o":
if s[i : i + 3] == "one":
q.add(i + 2)
elif s[i] == "t":
if s[i : i + 3] == "two":
q.add(i + 2)
print(len(q))
print(*q) | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP FUNC_CALL VAR STRING FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR STRING IF VAR VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR STRING STRING FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR STRING IF VAR VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR VAR STRING IF VAR VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR |
You are given a non-empty string s=s_1s_2... 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 β€ j β€ n-2), that s_{j}s_{j+1}s_{j+2}="one" or s_{j}s_{j+1}s_{j+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 β€ 10^4) β 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β
10^5. 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β
10^6.
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".
In the second example, answers are:
* "onetwonetwooneooonetwooo",
* "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". | t = int(input())
for i in range(t):
x, ans = str(input()), []
next = -1
for i in range(len(x) - 2):
if i < next:
continue
if x[i] == "t" and x[i + 1] == "w" and x[i + 2] == "o":
if i + 3 <= len(x) - 1 and x[i + 3] == "o":
ans.append(i + 2)
else:
ans.append(i + 3)
next = i + 3
if x[i] == "o" and x[i + 1] == "n" and x[i + 2] == "e":
ans.append(i + 2)
next = i + 3
print(len(ans))
for i in range(len(ans)):
print(ans[i], end=" ")
print("")
ans.clear | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR VAR IF VAR VAR STRING VAR BIN_OP VAR NUMBER STRING VAR BIN_OP VAR NUMBER STRING IF BIN_OP VAR NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF VAR VAR STRING VAR BIN_OP VAR NUMBER STRING VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR STRING EXPR FUNC_CALL VAR STRING EXPR VAR |
You are given a non-empty string s=s_1s_2... 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 β€ j β€ n-2), that s_{j}s_{j+1}s_{j+2}="one" or s_{j}s_{j+1}s_{j+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 β€ 10^4) β 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β
10^5. 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β
10^6.
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".
In the second example, answers are:
* "onetwonetwooneooonetwooo",
* "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". | for _ in range(int(input())):
s = input()
lst = []
n = len(s)
i = 0
while i < n:
if s[i] == "t":
if s[i : i + 5] == "twone":
lst.append(i + 2 + 1)
i += 5
elif s[i : i + 3] == "two":
lst.append(i + 2)
i += 3
else:
i += 1
elif s[i] == "o":
if s[i : i + 3] == "one":
lst.append(i + 2)
i += 3
else:
i += 1
else:
i += 1
print(len(lst))
if lst:
print(*lst)
else:
print("") | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER WHILE VAR VAR IF VAR VAR STRING IF VAR VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER NUMBER VAR NUMBER IF VAR VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER VAR NUMBER IF VAR VAR STRING IF VAR VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR STRING |
You are given a non-empty string s=s_1s_2... 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 β€ j β€ n-2), that s_{j}s_{j+1}s_{j+2}="one" or s_{j}s_{j+1}s_{j+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 β€ 10^4) β 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β
10^5. 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β
10^6.
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".
In the second example, answers are:
* "onetwonetwooneooonetwooo",
* "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". | import sys
sin = sys.stdin
t = int(sin.readline())
for i in range(t):
s = sin.readline()
idx = set()
twones = 0
j = 0
while j < len(s) - 3:
if j < len(s) - 4 and s[j : j + 5] == "twone":
idx.add(str(j + 3))
j += 5
elif s[j : j + 3] == "one" or s[j : j + 3] == "two":
idx.add(str(j + 2))
j += 3
else:
j += 1
print(len(idx))
print(" ".join(idx)) | IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR BIN_OP FUNC_CALL VAR VAR NUMBER VAR VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER IF VAR VAR BIN_OP VAR NUMBER STRING VAR VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL STRING VAR |
You are given a non-empty string s=s_1s_2... 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 β€ j β€ n-2), that s_{j}s_{j+1}s_{j+2}="one" or s_{j}s_{j+1}s_{j+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 β€ 10^4) β 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β
10^5. 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β
10^6.
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".
In the second example, answers are:
* "onetwonetwooneooonetwooo",
* "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". | import sys
input = sys.stdin.readline
n = int(input())
for i in range(n):
s = input().rstrip()
sl = list(s)
ans = set()
for i in range(len(s) - 2):
if s[i : i + 3] == "one" or s[i : i + 3] == "two":
ans.add(i + 2)
for i in range(len(s) - 4):
if s[i : i + 5] == "twone":
ans.add(i + 3)
ans.remove(i + 2)
ans.remove(i + 4)
print(len(ans))
print(*ans) | IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR VAR BIN_OP VAR NUMBER STRING VAR VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR |
You are given a non-empty string s=s_1s_2... 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 β€ j β€ n-2), that s_{j}s_{j+1}s_{j+2}="one" or s_{j}s_{j+1}s_{j+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 β€ 10^4) β 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β
10^5. 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β
10^6.
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".
In the second example, answers are:
* "onetwonetwooneooonetwooo",
* "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". | for _ in range(int(input())):
s = input()
x = len(s)
ans = []
i = 0
while i < x:
if s[i : i + 5] == "twone":
ans.append(i + 2)
i += 5
elif s[i : i + 3] == "two":
ans.append(i + 1)
i += 1
elif s[i : i + 3] == "one":
ans.append(i + 1)
i += 1
else:
i += 1
print(len(ans))
for an in ans:
print(an + 1, end=" ")
print() | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST ASSIGN VAR NUMBER WHILE VAR VAR IF VAR VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER IF VAR VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER IF VAR VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR FOR VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR |
You are given a non-empty string s=s_1s_2... 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 β€ j β€ n-2), that s_{j}s_{j+1}s_{j+2}="one" or s_{j}s_{j+1}s_{j+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 β€ 10^4) β 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β
10^5. 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β
10^6.
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".
In the second example, answers are:
* "onetwonetwooneooonetwooo",
* "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". | t = int(input())
for tt in range(t):
s = input().strip()
arr = []
for i in s:
arr.append(i)
ans = []
for i in range(len(s)):
if i + 4 < len(s):
if (
arr[i] == "t"
and arr[i + 1] == "w"
and arr[i + 2] == "o"
and arr[i + 3] == "n"
and arr[i + 4] == "e"
):
arr[i + 2] = "x"
ans.append(i + 2)
else:
break
for i in range(len(s)):
if i + 2 < len(s):
if arr[i] == "o" and arr[i + 1] == "n" and arr[i + 2] == "e":
arr[i + 1] == "x"
ans.append(i + 1)
elif arr[i] == "t" and arr[i + 1] == "w" and arr[i + 2] == "o":
arr[i + 2] == "x"
ans.append(i + 1)
print(len(ans))
for i in ans:
print(i + 1, end=" ")
print() | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER FUNC_CALL VAR VAR IF VAR VAR STRING VAR BIN_OP VAR NUMBER STRING VAR BIN_OP VAR NUMBER STRING VAR BIN_OP VAR NUMBER STRING VAR BIN_OP VAR NUMBER STRING ASSIGN VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER FUNC_CALL VAR VAR IF VAR VAR STRING VAR BIN_OP VAR NUMBER STRING VAR BIN_OP VAR NUMBER STRING EXPR VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR VAR STRING VAR BIN_OP VAR NUMBER STRING VAR BIN_OP VAR NUMBER STRING EXPR VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR FOR VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR |
You are given a non-empty string s=s_1s_2... 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 β€ j β€ n-2), that s_{j}s_{j+1}s_{j+2}="one" or s_{j}s_{j+1}s_{j+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 β€ 10^4) β 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β
10^5. 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β
10^6.
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".
In the second example, answers are:
* "onetwonetwooneooonetwooo",
* "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". | for _ in [0] * int(input()):
a = input()
f = []
prev_o = -1
for j in range(len(a) - 2):
if a[j] == "t" and a[j + 1] == "w" and a[j + 2] == "o":
if j + 3 is not len(a) and a[j + 3] == "n":
f.append(j + 2 + 1)
prev_o = j + 2
else:
f.append(j + 1 + 1)
elif a[j] == "o" and a[j + 1] == "n" and a[j + 2] == "e" and prev_o is not j:
f.append(j + 1 + 1)
print(len(f))
print(*f) | FOR VAR BIN_OP LIST NUMBER FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR VAR STRING VAR BIN_OP VAR NUMBER STRING VAR BIN_OP VAR NUMBER STRING IF BIN_OP VAR NUMBER FUNC_CALL VAR VAR VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER NUMBER IF VAR VAR STRING VAR BIN_OP VAR NUMBER STRING VAR BIN_OP VAR NUMBER STRING VAR VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR |
You are given a non-empty string s=s_1s_2... 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 β€ j β€ n-2), that s_{j}s_{j+1}s_{j+2}="one" or s_{j}s_{j+1}s_{j+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 β€ 10^4) β 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β
10^5. 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β
10^6.
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".
In the second example, answers are:
* "onetwonetwooneooonetwooo",
* "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". | t = int(input())
while t:
t -= 1
a = input()
l = len(a)
s = ["z", "z"]
flag1, flag2 = 0, 0
co = 0
flag3 = 0
res = []
for i in range(l):
s.append(a[i])
if flag1 == 1:
if a[i] == "e":
ind_[2] = i
flag3 = 1
else:
co += 1
if flag3 == 1:
res.append(ind_[1])
flag3 = 0
else:
res.append(ind_[2])
flag3 = 0
flag1 = 0
continue
if flag2 == 1:
if a[i] == "o":
ind_[2] = i
flag3 = 1
else:
co += 1
if flag3 == 1:
res.append(ind_[1])
flag3 = 0
else:
if a[i] == "n":
s.append("z")
res.append(ind_[2])
flag3 = 0
flag2 = 0
continue
if s[-3] + s[-2] + s[-1] == "one":
ind_ = [i - 1, i, 1 + i]
flag1 = 1
flag2 = 0
elif s[-3] + s[-2] + s[-1] == "two":
ind_ = [i - 1, i, i + 1]
flag2 = 1
flag1 = 0
if flag1 == 1 or flag2 == 1:
co += 1
res.append(ind_[1])
print(co)
print(*res) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST STRING STRING ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR IF VAR NUMBER IF VAR VAR STRING ASSIGN VAR NUMBER VAR ASSIGN VAR NUMBER VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER EXPR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER IF VAR VAR STRING ASSIGN VAR NUMBER VAR ASSIGN VAR NUMBER VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER IF VAR VAR STRING EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF BIN_OP BIN_OP VAR NUMBER VAR NUMBER VAR NUMBER STRING ASSIGN VAR LIST BIN_OP VAR NUMBER VAR BIN_OP NUMBER VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF BIN_OP BIN_OP VAR NUMBER VAR NUMBER VAR NUMBER STRING ASSIGN VAR LIST BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR |
You are given a non-empty string s=s_1s_2... 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 β€ j β€ n-2), that s_{j}s_{j+1}s_{j+2}="one" or s_{j}s_{j+1}s_{j+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 β€ 10^4) β 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β
10^5. 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β
10^6.
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".
In the second example, answers are:
* "onetwonetwooneooonetwooo",
* "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". | def f(s):
i = 0
start = 0
a = list(s)
r = []
while i != -1:
i = s.find("twone", start)
if i != -1:
a[i + 2] = "z"
r.append(i + 2 + 1)
start = i + 5
s = "".join(a)
i = 0
start = 0
while i != -1:
i = s.find("two", start)
if i != -1:
a[i + 1] = "z"
r.append(i + 1 + 1)
start = i + 2
s = "".join(a)
i = 0
start = 0
while i != -1:
i = s.find("one", start)
if i != -1:
a[i + 1] = "z"
r.append(i + 1 + 1)
start = i + 2
print(len(r))
print(*r)
t = int(input())
for i in range(t):
s = input()
f(s) | FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST WHILE VAR NUMBER ASSIGN VAR FUNC_CALL VAR STRING VAR IF VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL STRING VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR NUMBER ASSIGN VAR FUNC_CALL VAR STRING VAR IF VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL STRING VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR NUMBER ASSIGN VAR FUNC_CALL VAR STRING VAR IF VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR EXPR FUNC_CALL VAR VAR |
You are given a non-empty string s=s_1s_2... 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 β€ j β€ n-2), that s_{j}s_{j+1}s_{j+2}="one" or s_{j}s_{j+1}s_{j+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 β€ 10^4) β 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β
10^5. 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β
10^6.
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".
In the second example, answers are:
* "onetwonetwooneooonetwooo",
* "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". | def one_two(s):
ch1 = "one"
ch2 = "two"
ch3 = "twone"
final = ""
i = 0
count = 0
l = []
while i < len(s):
if s[i : i + 5] == ch3:
l.append(i + 3)
i = i + 5
elif s[i : i + 3] == ch1 or s[i : i + 3] == ch2:
l.append(i + 2)
i = i + 3
else:
i = i + 1
print(len(l))
print(*l)
n = int(input())
for i in range(0, n):
s = input()
one_two(s) | FUNC_DEF ASSIGN VAR STRING ASSIGN VAR STRING ASSIGN VAR STRING ASSIGN VAR STRING ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST WHILE VAR FUNC_CALL VAR VAR IF VAR VAR BIN_OP VAR NUMBER VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF VAR VAR BIN_OP VAR NUMBER VAR VAR VAR BIN_OP VAR NUMBER VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR EXPR FUNC_CALL VAR VAR |
You are given a non-empty string s=s_1s_2... 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 β€ j β€ n-2), that s_{j}s_{j+1}s_{j+2}="one" or s_{j}s_{j+1}s_{j+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 β€ 10^4) β 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β
10^5. 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β
10^6.
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".
In the second example, answers are:
* "onetwonetwooneooonetwooo",
* "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". | for _ in range(int(input())):
Answer = []
X = input()
Size = len(X)
Check = [0] * Size
for i in range(Size - 2):
if X[i] + X[i + 1] + X[i + 2] == "one":
Check[i] += 1
for i in range(Size - 2):
if X[i] + X[i + 1] + X[i + 2] == "two":
Check[i] += 3
Check[i + 2] += 4
i = 0
while i < Size - 2:
if Check[i] in [2, 5]:
Answer.append(i + 1)
i += 2
elif Check[i] == 3 and Check[i + 2] != 5 or Check[i] == 1:
Answer.append(i + 2)
i += 2
else:
i += 1
print(len(Answer))
print(*Answer) | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF BIN_OP BIN_OP VAR VAR VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER STRING VAR VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF BIN_OP BIN_OP VAR VAR VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER STRING VAR VAR NUMBER VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR NUMBER WHILE VAR BIN_OP VAR NUMBER IF VAR VAR LIST NUMBER NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER IF VAR VAR NUMBER VAR BIN_OP VAR NUMBER NUMBER VAR VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR |
You are given a non-empty string s=s_1s_2... 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 β€ j β€ n-2), that s_{j}s_{j+1}s_{j+2}="one" or s_{j}s_{j+1}s_{j+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 β€ 10^4) β 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β
10^5. 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β
10^6.
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".
In the second example, answers are:
* "onetwonetwooneooonetwooo",
* "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". | t = int(input())
for ti in range(t):
indices = []
s = input()
i = 0
while i < len(s):
if s[i] == "o" and s[i : i + 3] == "one":
indices += [i + 1]
i += 3
continue
elif s[i] == "t":
if s[i : i + 5] == "twone":
indices += [i + 2]
i += 5
elif s[i : i + 3] == "two":
indices += [i + 1]
i += 3
else:
i += 1
continue
i += 1
print(len(indices))
for i in indices:
print(i + 1, end=" ")
print() | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER WHILE VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR VAR BIN_OP VAR NUMBER STRING VAR LIST BIN_OP VAR NUMBER VAR NUMBER IF VAR VAR STRING IF VAR VAR BIN_OP VAR NUMBER STRING VAR LIST BIN_OP VAR NUMBER VAR NUMBER IF VAR VAR BIN_OP VAR NUMBER STRING VAR LIST BIN_OP VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR FOR VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR |
You are given a non-empty string s=s_1s_2... 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 β€ j β€ n-2), that s_{j}s_{j+1}s_{j+2}="one" or s_{j}s_{j+1}s_{j+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 β€ 10^4) β 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β
10^5. 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β
10^6.
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".
In the second example, answers are:
* "onetwonetwooneooonetwooo",
* "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". | from sys import stdin
for _ in range(int(input())):
s = list(stdin.readline().rstrip())
l = len(s)
z = []
for i in range(1, l - 1):
if s[i] == "n":
if s[i - 1] == "o" and s[i + 1] == "e":
z.append(i + 1)
s[i - 1] = s[i + 1] = s[i] = "-"
if s[i] == "w":
if len(s) - 1 - i - 3 >= 0:
if s[i - 1] == "t" and s[i + 1] == "o":
if s[i + 2] == "n" and s[i + 3] == "e":
z.append(i + 2)
s[i - 1] = s[i] = s[i + 1] = s[i + 2] = s[i + 3] = "-"
else:
z.append(i + 1)
s[i - 1] = s[i] = s[i + 1] = "-"
elif s[i - 1] == "t" and s[i + 1] == "o":
z.append(i + 1)
s[i - 1] = s[i] = s[i + 1] = "-"
print(len(z))
print(*z) | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER IF VAR VAR STRING IF VAR BIN_OP VAR NUMBER STRING VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER VAR VAR STRING IF VAR VAR STRING IF BIN_OP BIN_OP BIN_OP FUNC_CALL VAR VAR NUMBER VAR NUMBER NUMBER IF VAR BIN_OP VAR NUMBER STRING VAR BIN_OP VAR NUMBER STRING IF VAR BIN_OP VAR NUMBER STRING VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER VAR VAR VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER VAR VAR VAR BIN_OP VAR NUMBER STRING IF VAR BIN_OP VAR NUMBER STRING VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER VAR VAR VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR |
You are given a non-empty string s=s_1s_2... 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 β€ j β€ n-2), that s_{j}s_{j+1}s_{j+2}="one" or s_{j}s_{j+1}s_{j+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 β€ 10^4) β 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β
10^5. 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β
10^6.
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".
In the second example, answers are:
* "onetwonetwooneooonetwooo",
* "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". | t = int(input())
while t > 0:
t -= 1
s = list(input().strip())
n = len(s)
change = 0
ans = []
for i in range(n - 4):
if "".join(s[i : i + 5]) == "twone":
s[i + 2] = "-"
change += 1
ans.append(i + 3)
for i in range(n - 2):
val = "".join(s[i : i + 3])
if val == "one" or val == "two":
s[i + 1] = "-"
change += 1
ans.append(i + 2)
if change > 0:
print(change)
print(" ".join(map(str, ans)))
else:
print(change)
print() | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF FUNC_CALL STRING VAR VAR BIN_OP VAR NUMBER STRING ASSIGN VAR BIN_OP VAR NUMBER STRING VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL STRING VAR VAR BIN_OP VAR NUMBER IF VAR STRING VAR STRING ASSIGN VAR BIN_OP VAR NUMBER STRING VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL STRING FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR |
You are given a non-empty string s=s_1s_2... 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 β€ j β€ n-2), that s_{j}s_{j+1}s_{j+2}="one" or s_{j}s_{j+1}s_{j+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 β€ 10^4) β 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β
10^5. 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β
10^6.
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".
In the second example, answers are:
* "onetwonetwooneooonetwooo",
* "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". | for yut in range(int(input())):
s = input()
n = len(s)
l = 0
count = 0
cont = []
b = True
while l < n:
b = True
if l + 5 <= n:
if s[l : l + 5] == "twone":
count += 1
cont.append(str(l + 3))
l += 4
b = False
if l > n - 1:
break
if b:
if l + 3 <= n:
if s[l : l + 3] == "two" or s[l : l + 3] == "one":
count += 1
cont.append(str(l + 2))
l += 2
l += 1
print(count)
print(" ".join(cont)) | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN VAR NUMBER IF BIN_OP VAR NUMBER VAR IF VAR VAR BIN_OP VAR NUMBER STRING VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER IF VAR BIN_OP VAR NUMBER IF VAR IF BIN_OP VAR NUMBER VAR IF VAR VAR BIN_OP VAR NUMBER STRING VAR VAR BIN_OP VAR NUMBER STRING VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL STRING VAR |
You are given a non-empty string s=s_1s_2... 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 β€ j β€ n-2), that s_{j}s_{j+1}s_{j+2}="one" or s_{j}s_{j+1}s_{j+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 β€ 10^4) β 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β
10^5. 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β
10^6.
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".
In the second example, answers are:
* "onetwonetwooneooonetwooo",
* "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". | for _ in range(int(input())):
s = input()
one = s.count("one")
two = s.count("two")
twone = s.count("twone")
ans = one + two - twone
l = []
i = 0
while i < len(s) - 2:
if s[i : i + 3] == "one":
l.append(i + 1)
i += 3
elif i + 4 < len(s) and s[i : i + 5] == "twone":
l.append(i + 2)
i += 5
elif s[i : i + 3] == "two":
l.append(i + 1)
i += 3
else:
i += 1
print(ans)
[print(i + 1, end=" ") for i in l]
print() | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR ASSIGN VAR LIST ASSIGN VAR NUMBER WHILE VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER IF BIN_OP VAR NUMBER FUNC_CALL VAR VAR VAR VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER IF VAR VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER STRING VAR VAR EXPR FUNC_CALL VAR |
You are given a non-empty string s=s_1s_2... 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 β€ j β€ n-2), that s_{j}s_{j+1}s_{j+2}="one" or s_{j}s_{j+1}s_{j+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 β€ 10^4) β 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β
10^5. 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β
10^6.
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".
In the second example, answers are:
* "onetwonetwooneooonetwooo",
* "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". | s = int(input())
def find_answer(string):
n = len(string)
if "one" not in string and "two" not in string:
return []
res = []
if string[:3] == "one":
res.append("2")
if string[1:4] == "one":
res.append("3")
for i in range(n - 2):
if string[i : i + 5] == "twone":
res.append(str(i + 3))
elif string[i : i + 3] == "two":
res.append(str(i + 2))
elif i >= 2 and string[i - 2 : i + 3] != "twone" and string[i : i + 3] == "one":
res.append(str(i + 2))
return res
for _ in range(s):
string = str(input())
ans = find_answer(string)
print(len(ans))
print(" ".join(ans)) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR IF STRING VAR STRING VAR RETURN LIST ASSIGN VAR LIST IF VAR NUMBER STRING EXPR FUNC_CALL VAR STRING IF VAR NUMBER NUMBER STRING EXPR FUNC_CALL VAR STRING FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR NUMBER VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER STRING VAR VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR NUMBER RETURN VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL STRING VAR |
You are given a non-empty string s=s_1s_2... 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 β€ j β€ n-2), that s_{j}s_{j+1}s_{j+2}="one" or s_{j}s_{j+1}s_{j+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 β€ 10^4) β 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β
10^5. 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β
10^6.
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".
In the second example, answers are:
* "onetwonetwooneooonetwooo",
* "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". | ones = "one"
one = 0
twos = "two"
two = 0
for i in range(int(input())):
one, two = 0, 0
s = input()
cnt = 0
a = list()
for j in range(len(s)):
if s[j] == ones[one]:
one += 1
elif s[j] == ones[0]:
one = 1
else:
one = 0
if s[j] == twos[two]:
two += 1
elif s[j] == twos[0]:
two = 1
else:
two = 0
if two == 3:
if j < len(s) - 1 and s[j + 1] == "n":
one = 0
a.append(j + 1)
else:
a.append(j)
two = 0
cnt += 1
if one == 3:
a.append(j)
one = 0
cnt += 1
two = 0
print(cnt)
print(*a) | ASSIGN VAR STRING ASSIGN VAR NUMBER ASSIGN VAR STRING ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR VAR NUMBER IF VAR VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF VAR VAR VAR VAR VAR NUMBER IF VAR VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER IF VAR BIN_OP FUNC_CALL VAR VAR NUMBER VAR BIN_OP VAR NUMBER STRING ASSIGN VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR |
You are given a non-empty string s=s_1s_2... 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 β€ j β€ n-2), that s_{j}s_{j+1}s_{j+2}="one" or s_{j}s_{j+1}s_{j+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 β€ 10^4) β 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β
10^5. 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β
10^6.
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".
In the second example, answers are:
* "onetwonetwooneooonetwooo",
* "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". | for tc in range(int(input())):
s = list(input())
temp = []
i = 0
f = 1
a = 1
while i < len(s):
if s[i] == "o":
if "".join(s[i : i + 3]) == "one":
c = 1
temp.append(i + 1)
k = i + 3
f = 1
if f:
i += 3
else:
i = k
a = 3
continue
elif s[i] == "t":
if "".join(s[i : i + 5]) == "twone":
c = 0
temp.append(i + 2)
i += 5
continue
elif "".join(s[i : i + 3]) == "two":
temp.append(i + 1)
k = i + 3
f = 1
if f:
i += 3
else:
i = k
continue
i = i + 1
l = list(set(temp))
print(len(l))
if len(l) == 0:
print()
else:
for i in range(len(l)):
if i != len(l) - 1:
print(l[i] + 1, end=" ")
else:
print(l[i] + 1) | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR FUNC_CALL VAR VAR IF VAR VAR STRING IF FUNC_CALL STRING VAR VAR BIN_OP VAR NUMBER STRING ASSIGN VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER IF VAR VAR NUMBER ASSIGN VAR VAR ASSIGN VAR NUMBER IF VAR VAR STRING IF FUNC_CALL STRING VAR VAR BIN_OP VAR NUMBER STRING ASSIGN VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER IF FUNC_CALL STRING VAR VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER IF VAR VAR NUMBER ASSIGN VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR BIN_OP FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR VAR NUMBER STRING EXPR FUNC_CALL VAR BIN_OP VAR VAR NUMBER |
You are given a non-empty string s=s_1s_2... 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 β€ j β€ n-2), that s_{j}s_{j+1}s_{j+2}="one" or s_{j}s_{j+1}s_{j+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 β€ 10^4) β 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β
10^5. 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β
10^6.
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".
In the second example, answers are:
* "onetwonetwooneooonetwooo",
* "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". | q = int(input())
for _ in range(q):
s = input()
n = len(s)
dp = [(0) for i in range(n)]
for i in range(4, n):
if s[i - 4] + s[i - 3] + s[i - 2] + s[i - 1] + s[i] == "twone":
dp[i - 4] = 1
dp[i - 2] = 2
dp[i] = 1
for i in range(2, n):
if s[i - 2] + s[i - 1] + s[i] == "one" and dp[i] != 1:
dp[i] = 1
dp[i - 2] = 1
dp[i - 1] = 2
for i in range(2, n):
if s[i - 2] + s[i - 1] + s[i] == "two" and dp[i] != 2:
dp[i] = 1
dp[i - 2] = 1
dp[i - 1] = 2
ans = []
res = 0
for i in range(n):
if dp[i] == 2:
res += 1
ans.append(i + 1)
print(res)
for i in range(res):
print(ans[i], end=" ") | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER VAR IF BIN_OP BIN_OP BIN_OP BIN_OP VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER VAR VAR STRING ASSIGN VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF BIN_OP BIN_OP VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER VAR VAR STRING VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF BIN_OP BIN_OP VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER VAR VAR STRING VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR STRING |
You are given a non-empty string s=s_1s_2... 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 β€ j β€ n-2), that s_{j}s_{j+1}s_{j+2}="one" or s_{j}s_{j+1}s_{j+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 β€ 10^4) β 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β
10^5. 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β
10^6.
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".
In the second example, answers are:
* "onetwonetwooneooonetwooo",
* "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". | from sys import stdin
def input():
return stdin.readline()[:-1]
def intput():
return int(input())
def sinput():
return input().split()
def intsput():
return map(int, sinput())
t = intput()
one = list("one")
two = list("two")
for _ in range(t):
s = input()
s = list(s)
cnt = 0
targets = []
for i in range(len(s) - 2):
inspect = s[i : i + 3]
if inspect == one:
if i == 0 or s[i - 1] != "o":
cnt += 1
targets.append(i + 1)
s[i] = "."
else:
cnt += 1
targets.append(i + 2)
s[i + 1] = "."
elif inspect == two:
if i == len(s) - 3 or s[i + 3] != "o":
cnt += 1
targets.append(i + 3)
s[i + 2] = "."
else:
cnt += 1
targets.append(i + 2)
s[i + 1] = "."
print(cnt)
print(*targets) | FUNC_DEF RETURN FUNC_CALL VAR NUMBER FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR VAR BIN_OP VAR NUMBER IF VAR VAR IF VAR NUMBER VAR BIN_OP VAR NUMBER STRING VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR VAR STRING VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER STRING IF VAR VAR IF VAR BIN_OP FUNC_CALL VAR VAR NUMBER VAR BIN_OP VAR NUMBER STRING VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER STRING VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR |
You are given a non-empty string s=s_1s_2... 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 β€ j β€ n-2), that s_{j}s_{j+1}s_{j+2}="one" or s_{j}s_{j+1}s_{j+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 β€ 10^4) β 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β
10^5. 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β
10^6.
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".
In the second example, answers are:
* "onetwonetwooneooonetwooo",
* "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". | for _ in range(int(input())):
s = input().strip()
cnt = 0
res = [(i + 2) for i in range(len(s)) if s.startswith("twone", i)]
cnt += len(res)
s = s.replace("twone", "tw1ne")
res1 = [(m + 1) for m in range(len(s)) if s.startswith("one", m)]
res.extend(res1)
x = len(res1)
s = s.replace("one", "o1e")
res2 = [(b + 1) for b in range(len(s)) if s.startswith("two", b)]
y = len(res2)
res.extend(res2)
cnt += x + y
print(cnt)
s = ""
for i in range(len(res)):
res[i] += 1
s += str(res[i]) + " "
print(s) | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR STRING VAR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR STRING STRING ASSIGN VAR BIN_OP VAR NUMBER VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR STRING VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR STRING STRING ASSIGN VAR BIN_OP VAR NUMBER VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR STRING VAR ASSIGN VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR STRING FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR NUMBER VAR BIN_OP FUNC_CALL VAR VAR VAR STRING EXPR FUNC_CALL VAR VAR |
You are given a non-empty string s=s_1s_2... 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 β€ j β€ n-2), that s_{j}s_{j+1}s_{j+2}="one" or s_{j}s_{j+1}s_{j+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 β€ 10^4) β 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β
10^5. 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β
10^6.
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".
In the second example, answers are:
* "onetwonetwooneooonetwooo",
* "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". | t = int(input())
for _ in range(t):
s = list(input())
n = len(s)
ans = []
i = 0
while i < n:
if "".join(s[i : i + 5]) == "twone":
ans.append(i + 3)
s[i + 2] = "?"
i += 5
elif "".join(s[i : i + 3]) == "one":
ans.append(i + 2)
s[i + 1] = "?"
i += 3
elif "".join(s[i : i + 3]) == "two":
ans.append(i + 2)
s[i + 1] = "?"
i += 3
else:
i += 1
print(len(ans))
print(" ".join(map(str, ans))) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST ASSIGN VAR NUMBER WHILE VAR VAR IF FUNC_CALL STRING VAR VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER STRING VAR NUMBER IF FUNC_CALL STRING VAR VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER STRING VAR NUMBER IF FUNC_CALL STRING VAR VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER STRING VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL STRING FUNC_CALL VAR VAR VAR |
You are given a non-empty string s=s_1s_2... 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 β€ j β€ n-2), that s_{j}s_{j+1}s_{j+2}="one" or s_{j}s_{j+1}s_{j+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 β€ 10^4) β 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β
10^5. 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β
10^6.
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".
In the second example, answers are:
* "onetwonetwooneooonetwooo",
* "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". | for _ in range(int(input())):
a = list(input())
ret = []
for i, ch in enumerate(a):
if (
ch == "o"
and i - 2 >= 0
and i + 2 < len(a)
and "".join(a[i - 2 : i + 3]) == "twone"
):
ret.append(i + 1)
a[i] = "z"
stack = []
for i, ch in enumerate(a):
if len(stack) >= 2 and stack[-2][0] + stack[-1][0] + ch in ("one", "two"):
mid = stack.pop()
ret.append(mid[1] + 1)
stack.append((ch, i))
else:
stack.append((ch, i))
print(len(ret))
print(*ret) | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR VAR FUNC_CALL VAR VAR IF VAR STRING BIN_OP VAR NUMBER NUMBER BIN_OP VAR NUMBER FUNC_CALL VAR VAR FUNC_CALL STRING VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR VAR STRING ASSIGN VAR LIST FOR VAR VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR NUMBER BIN_OP BIN_OP VAR NUMBER NUMBER VAR NUMBER NUMBER VAR STRING STRING ASSIGN VAR FUNC_CALL VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR |
You are given a non-empty string s=s_1s_2... 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 β€ j β€ n-2), that s_{j}s_{j+1}s_{j+2}="one" or s_{j}s_{j+1}s_{j+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 β€ 10^4) β 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β
10^5. 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β
10^6.
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".
In the second example, answers are:
* "onetwonetwooneooonetwooo",
* "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". | import sys
tests = int(sys.stdin.readline())
for _ in range(tests):
stringg = str(sys.stdin.readline())
if stringg.count("one") == 0 and stringg.count("two") == 0:
print("0")
print()
else:
cnt = 0
indexesBothResult = []
indexesBoth = []
indexes = []
for index, value in enumerate(stringg):
if stringg[index : index + len("twone")] == "twone":
cnt += 1
indexesBoth.append(index + 2)
indexesBoth.append(index)
indexesBothResult.append(index + 3)
for index, value in enumerate(stringg):
if stringg[index : index + len("two")] == "two":
if index not in indexesBoth:
cnt += 1
indexes.append(index + 2)
for index, value in enumerate(stringg):
if stringg[index : index + len("one")] == "one":
if index not in indexesBoth:
cnt += 1
indexes.append(index + 2)
print(cnt)
for i in range(len(indexesBothResult)):
print(indexesBothResult[i], end=" ")
for i in range(len(indexes)):
print(indexes[i], end=" ")
print() | IMPORT ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF FUNC_CALL VAR STRING NUMBER FUNC_CALL VAR STRING NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR VAR FUNC_CALL VAR VAR IF VAR VAR BIN_OP VAR FUNC_CALL VAR STRING STRING VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER FOR VAR VAR FUNC_CALL VAR VAR IF VAR VAR BIN_OP VAR FUNC_CALL VAR STRING STRING IF VAR VAR VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER FOR VAR VAR FUNC_CALL VAR VAR IF VAR VAR BIN_OP VAR FUNC_CALL VAR STRING STRING IF VAR VAR VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR STRING FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR STRING EXPR FUNC_CALL VAR |
You are given a non-empty string s=s_1s_2... 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 β€ j β€ n-2), that s_{j}s_{j+1}s_{j+2}="one" or s_{j}s_{j+1}s_{j+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 β€ 10^4) β 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β
10^5. 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β
10^6.
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".
In the second example, answers are:
* "onetwonetwooneooonetwooo",
* "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". | t = int(input())
for _ in range(t):
s = input()
if len(s) < 3:
print(0)
continue
ans = []
for i in range(len(s)):
if i < 2:
if s[i : i + 3] == "one":
ans.append(i + 1)
elif i + 2 < len(s) and s[i - 2 : i + 3] == "twone":
ans.append(i)
elif s[i - 2 : i + 1] == "two":
ans.append(i - 1)
elif i + 2 < len(s) and s[i : i + 3] == "one":
ans.append(i + 1)
ans.sort()
print(len(ans))
for j in ans:
print(j + 1, end=" ")
print(end="\n") | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR IF FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR NUMBER IF VAR VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR BIN_OP VAR NUMBER IF BIN_OP VAR NUMBER FUNC_CALL VAR VAR VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR VAR IF VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR BIN_OP VAR NUMBER IF BIN_OP VAR NUMBER FUNC_CALL VAR VAR VAR VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR FOR VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR STRING |
You are given a non-empty string s=s_1s_2... 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 β€ j β€ n-2), that s_{j}s_{j+1}s_{j+2}="one" or s_{j}s_{j+1}s_{j+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 β€ 10^4) β 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β
10^5. 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β
10^6.
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".
In the second example, answers are:
* "onetwonetwooneooonetwooo",
* "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". | def solve(string):
n = len(string)
i = 0
ans = []
while i < n:
if i + 4 < n and string[i : i + 5] == "twone":
ans.append(i + 2 + 1)
i += 5
elif i + 2 < n and (string[i : i + 3] == "one" or string[i : i + 3] == "two"):
ans.append(i + 1 + 1)
i += 3
else:
i += 1
print(len(ans))
print(" ".join(list(map(str, ans))))
for _ in range(int(input())):
solve(input()) | FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR LIST WHILE VAR VAR IF BIN_OP VAR NUMBER VAR VAR VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER NUMBER VAR NUMBER IF BIN_OP VAR NUMBER VAR VAR VAR BIN_OP VAR NUMBER STRING VAR VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER NUMBER VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL STRING FUNC_CALL VAR FUNC_CALL VAR VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_CALL VAR |
You are given a non-empty string s=s_1s_2... 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 β€ j β€ n-2), that s_{j}s_{j+1}s_{j+2}="one" or s_{j}s_{j+1}s_{j+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 β€ 10^4) β 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β
10^5. 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β
10^6.
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".
In the second example, answers are:
* "onetwonetwooneooonetwooo",
* "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". | x = int(input())
for _ in range(x):
a = input()
b = len(a)
lol = []
if b >= 3:
i = 0
j = 1
k = 2
while i < b - 2 and k < b:
if (a[i] + a[j] + a[k] == "one" or a[i] + a[j] + a[k] == "two") and k < b:
f = 0
if a[i] + a[j] + a[k] == "two" and k < b - 2:
if a[k] + a[k + 1] + a[k + 2] == "one":
lol.append(k + 1)
f = 1
i = k + 3
j = i + 1
k = j + 1
if f == 0:
lol.append(j + 1)
i += 1
j += 1
k += 1
else:
i += 1
j += 1
k += 1
print(len(lol))
print(*lol) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST IF VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR BIN_OP VAR NUMBER VAR VAR IF BIN_OP BIN_OP VAR VAR VAR VAR VAR VAR STRING BIN_OP BIN_OP VAR VAR VAR VAR VAR VAR STRING VAR VAR ASSIGN VAR NUMBER IF BIN_OP BIN_OP VAR VAR VAR VAR VAR VAR STRING VAR BIN_OP VAR NUMBER IF BIN_OP BIN_OP VAR VAR VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR |
You are given a non-empty string s=s_1s_2... 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 β€ j β€ n-2), that s_{j}s_{j+1}s_{j+2}="one" or s_{j}s_{j+1}s_{j+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 β€ 10^4) β 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β
10^5. 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β
10^6.
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".
In the second example, answers are:
* "onetwonetwooneooonetwooo",
* "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". | t = int(input())
for nt in range(t):
s = input()
i = 0
count = 0
ans = []
while i < len(s) - 2:
if s[i] == "t" and s[i + 1] == "w" and s[i + 2] == "o" and i + 4 >= len(s):
count += 1
ans.append(i + 2)
break
elif (
s[i] == "t"
and s[i + 1] == "w"
and s[i + 2] == "o"
and s[i + 3] == "n"
and s[i + 4] == "e"
):
count += 1
ans.append(i + 3)
i += 5
elif s[i] == "t" and s[i + 1] == "w" and s[i + 2] == "o":
count += 1
ans.append(i + 2)
i += 3
elif s[i] == "o" and s[i + 1] == "n" and s[i + 2] == "e":
count += 1
ans.append(i + 2)
i += 3
else:
i += 1
print(count)
print(*ans) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST WHILE VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR VAR STRING VAR BIN_OP VAR NUMBER STRING VAR BIN_OP VAR NUMBER STRING BIN_OP VAR NUMBER FUNC_CALL VAR VAR VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR VAR STRING VAR BIN_OP VAR NUMBER STRING VAR BIN_OP VAR NUMBER STRING VAR BIN_OP VAR NUMBER STRING VAR BIN_OP VAR NUMBER STRING VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER IF VAR VAR STRING VAR BIN_OP VAR NUMBER STRING VAR BIN_OP VAR NUMBER STRING VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER IF VAR VAR STRING VAR BIN_OP VAR NUMBER STRING VAR BIN_OP VAR NUMBER STRING VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR |
You are given a non-empty string s=s_1s_2... 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 β€ j β€ n-2), that s_{j}s_{j+1}s_{j+2}="one" or s_{j}s_{j+1}s_{j+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 β€ 10^4) β 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β
10^5. 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β
10^6.
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".
In the second example, answers are:
* "onetwonetwooneooonetwooo",
* "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". | t = int(input())
while t != 0:
t -= 1
s = input()
l = []
n = len(s)
for i in range(n - 4):
if (
s[i] == "t"
and s[i + 1] == "w"
and s[i + 2] == "o"
and s[i + 3] == "n"
and s[i + 4] == "e"
):
l.append(i + 2)
s = s[: i + 2] + "q" + s[i + 3 :]
for i in range(n - 2):
if s[i] == "t" and s[i + 1] == "w" and s[i + 2] == "o":
l.append(i + 1)
elif s[i] == "o" and s[i + 1] == "n" and s[i + 2] == "e":
l.append(i + 1)
print(len(l))
for i in l:
print(i + 1, end=" ")
print() | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR VAR STRING VAR BIN_OP VAR NUMBER STRING VAR BIN_OP VAR NUMBER STRING VAR BIN_OP VAR NUMBER STRING VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER STRING VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR VAR STRING VAR BIN_OP VAR NUMBER STRING VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR VAR STRING VAR BIN_OP VAR NUMBER STRING VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR FOR VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR |
You are given a non-empty string s=s_1s_2... 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 β€ j β€ n-2), that s_{j}s_{j+1}s_{j+2}="one" or s_{j}s_{j+1}s_{j+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 β€ 10^4) β 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β
10^5. 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β
10^6.
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".
In the second example, answers are:
* "onetwonetwooneooonetwooo",
* "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". | for _ in [0] * int(input()):
s = input()
i = 0
r = []
while i < len(s):
if "twone" == s[i : i + 5]:
i += 3
r.append(i)
continue
if s[i : i + 3] in ("one", "two"):
r.append(i + 2)
i += 1
continue
i += 1
print(len(r))
for i in r:
print(i, end=" ")
print() | FOR VAR BIN_OP LIST NUMBER FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR LIST WHILE VAR FUNC_CALL VAR VAR IF STRING VAR VAR BIN_OP VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR IF VAR VAR BIN_OP VAR NUMBER STRING STRING EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR FOR VAR VAR EXPR FUNC_CALL VAR VAR STRING EXPR FUNC_CALL VAR |
You are given a non-empty string s=s_1s_2... 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 β€ j β€ n-2), that s_{j}s_{j+1}s_{j+2}="one" or s_{j}s_{j+1}s_{j+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 β€ 10^4) β 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β
10^5. 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β
10^6.
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".
In the second example, answers are:
* "onetwonetwooneooonetwooo",
* "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". | from sys import stdin, stdout
for _ in range(int(stdin.readline())):
s = stdin.readline()[:-1]
lst = []
n = len(s)
i = 1
while i < n - 1:
if s[i] == "o" and (i > 1 and i < n - 2):
if s[i + 1 : i + 3] == "ne" and s[i - 2 : i] == "tw":
lst.append(i)
i += 2
elif s[i] == "n":
if s[i - 1 : i + 2] == "one":
lst.append(i)
i += 1
elif s[i] == "w":
if s[i - 1 : i + 2] == "two":
lst.append(i)
i += 1
length = len(lst)
for i in range(1, length):
if lst[i] - lst[i - 1] == 1:
lst[i - 1] = 0
length -= 1
stdout.write(str(length) + "\n")
for i in lst:
if i:
stdout.write(str(i + 1) + " ")
stdout.write("\n") | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR NUMBER ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER WHILE VAR BIN_OP VAR NUMBER IF VAR VAR STRING VAR NUMBER VAR BIN_OP VAR NUMBER IF VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER STRING VAR BIN_OP VAR NUMBER VAR STRING EXPR FUNC_CALL VAR VAR VAR NUMBER IF VAR VAR STRING IF VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR VAR VAR NUMBER IF VAR VAR STRING IF VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER VAR IF BIN_OP VAR VAR VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER NUMBER VAR NUMBER EXPR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR STRING FOR VAR VAR IF VAR EXPR FUNC_CALL VAR BIN_OP FUNC_CALL VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR STRING |
You are given a non-empty string s=s_1s_2... 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 β€ j β€ n-2), that s_{j}s_{j+1}s_{j+2}="one" or s_{j}s_{j+1}s_{j+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 β€ 10^4) β 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β
10^5. 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β
10^6.
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".
In the second example, answers are:
* "onetwonetwooneooonetwooo",
* "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". | for test in range(int(input())):
b = input()
a = []
c = []
for lol in range(len(b)):
a.append(b[lol])
for i in range(len(a) - 1, 3, -1):
if (
a[i - 4] == "t"
and a[i - 3] == "w"
and a[i - 2] == "o"
and a[i - 1] == "n"
and a[i] == "e"
):
a[i - 2] = "X"
c.append(i - 1)
for j in range(len(a) - 1, 1, -1):
if a[j - 2] == "o" and a[j - 1] == "n" and a[j] == "e":
a[j - 1] = "X"
c.append(j)
for k in range(len(a) - 1, 1, -1):
if a[k - 2] == "t" and a[k - 1] == "w" and a[k] == "o":
a[k - 1] = "X"
c.append(k)
print(len(c))
for l in range(len(c)):
print(c[l], end=" ")
print() | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER NUMBER IF VAR BIN_OP VAR NUMBER STRING VAR BIN_OP VAR NUMBER STRING VAR BIN_OP VAR NUMBER STRING VAR BIN_OP VAR NUMBER STRING VAR VAR STRING ASSIGN VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER NUMBER IF VAR BIN_OP VAR NUMBER STRING VAR BIN_OP VAR NUMBER STRING VAR VAR STRING ASSIGN VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER NUMBER IF VAR BIN_OP VAR NUMBER STRING VAR BIN_OP VAR NUMBER STRING VAR VAR STRING ASSIGN VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR STRING EXPR FUNC_CALL VAR |
You are given a non-empty string s=s_1s_2... 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 β€ j β€ n-2), that s_{j}s_{j+1}s_{j+2}="one" or s_{j}s_{j+1}s_{j+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 β€ 10^4) β 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β
10^5. 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β
10^6.
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".
In the second example, answers are:
* "onetwonetwooneooonetwooo",
* "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". | for _ in range(int(input())):
s = input()
n = len(s)
ct = 0
co = 0
two = set()
one = set()
for i in range(n - 2):
if s[i] == "o" and s[i + 1] == "n" and s[i + 2] == "e":
if i - 1 >= 0 and i - 2 >= 0 and s[i - 2] == "t" and s[i - 1] == "w":
one.add(i + 1)
else:
one.add(i + 2)
elif s[i] == "t" and s[i + 1] == "w" and s[i + 2] == "o":
if i + 3 < n and i + 4 < n and s[i + 3] == "n" and s[i + 4] == "e":
two.add(i + 3)
else:
two.add(i + 2)
k = one | two
print(len(k))
k = sorted(list(k))
print(*k) | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR VAR STRING VAR BIN_OP VAR NUMBER STRING VAR BIN_OP VAR NUMBER STRING IF BIN_OP VAR NUMBER NUMBER BIN_OP VAR NUMBER NUMBER VAR BIN_OP VAR NUMBER STRING VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR VAR STRING VAR BIN_OP VAR NUMBER STRING VAR BIN_OP VAR NUMBER STRING IF BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER VAR VAR BIN_OP VAR NUMBER STRING VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR |
You are given a non-empty string s=s_1s_2... 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 β€ j β€ n-2), that s_{j}s_{j+1}s_{j+2}="one" or s_{j}s_{j+1}s_{j+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 β€ 10^4) β 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β
10^5. 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β
10^6.
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".
In the second example, answers are:
* "onetwonetwooneooonetwooo",
* "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". | for _ in range(int(input())):
st = input()
deleted = set()
for i in range(2, len(st) - 2):
if (
st[i - 2] == "t"
and st[i - 1] == "w"
and st[i] == "o"
and st[i + 1] == "n"
and st[i + 2] == "e"
):
deleted.add(i)
for i in range(len(st) - 2):
if i not in deleted and st[i] == "o" and st[i + 1] == "n" and st[i + 2] == "e":
deleted.add(i + 1)
elif (
i + 2 not in deleted
and st[i] == "t"
and st[i + 1] == "w"
and st[i + 2] == "o"
):
deleted.add(i + 1)
print(len(deleted))
for i in deleted:
print(i + 1, end=" ")
print() | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR BIN_OP VAR NUMBER STRING VAR BIN_OP VAR NUMBER STRING VAR VAR STRING VAR BIN_OP VAR NUMBER STRING VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR VAR VAR VAR STRING VAR BIN_OP VAR NUMBER STRING VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR BIN_OP VAR NUMBER IF BIN_OP VAR NUMBER VAR VAR VAR STRING VAR BIN_OP VAR NUMBER STRING VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR FOR VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR |
You are given a non-empty string s=s_1s_2... 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 β€ j β€ n-2), that s_{j}s_{j+1}s_{j+2}="one" or s_{j}s_{j+1}s_{j+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 β€ 10^4) β 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β
10^5. 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β
10^6.
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".
In the second example, answers are:
* "onetwonetwooneooonetwooo",
* "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". | from sys import stdin
R = lambda: list(stdin.readline().rstrip("\n"))
for _ in range(int(input())):
a = R() + ["x"] * 3
v = []
for i in range(len(a) - 2):
if a[i] + a[i + 1] + a[i + 2] == "two":
if a[i + 2] + a[i + 3] + a[i + 4] == "one":
v += (i + 3,)
a[i + 2] = "x"
else:
v += (i + 2,)
a[i + 1] = "x"
elif a[i] + a[i + 1] + a[i + 2] == "one":
v += (i + 2,)
a[i + 1] = "x"
print(len(v))
print(*v) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR STRING FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP FUNC_CALL VAR BIN_OP LIST STRING NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF BIN_OP BIN_OP VAR VAR VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER STRING IF BIN_OP BIN_OP VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER STRING VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER STRING VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER STRING IF BIN_OP BIN_OP VAR VAR VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER STRING VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR |
You are given a non-empty string s=s_1s_2... 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 β€ j β€ n-2), that s_{j}s_{j+1}s_{j+2}="one" or s_{j}s_{j+1}s_{j+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 β€ 10^4) β 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β
10^5. 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β
10^6.
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".
In the second example, answers are:
* "onetwonetwooneooonetwooo",
* "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". | def main():
r = []
for _ in range(int(input())):
s = (
input()
.replace("twone", "tw_ne")
.replace("one", "o_e")
.replace("two", "t_o")
)
n = s.count("_")
r.append(str(n))
if n:
r.append(" ".join(map(str, [i for i, c in enumerate(s, 1) if c == "_"])))
print("\n".join(r))
main() | FUNC_DEF ASSIGN VAR LIST FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL FUNC_CALL FUNC_CALL VAR STRING STRING STRING STRING STRING STRING ASSIGN VAR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR EXPR FUNC_CALL VAR FUNC_CALL STRING FUNC_CALL VAR VAR VAR VAR VAR FUNC_CALL VAR VAR NUMBER VAR STRING EXPR FUNC_CALL VAR FUNC_CALL STRING VAR EXPR FUNC_CALL VAR |
You are given a non-empty string s=s_1s_2... 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 β€ j β€ n-2), that s_{j}s_{j+1}s_{j+2}="one" or s_{j}s_{j+1}s_{j+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 β€ 10^4) β 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β
10^5. 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β
10^6.
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".
In the second example, answers are:
* "onetwonetwooneooonetwooo",
* "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". | for _ in range(int(input())):
arr = input()
ln = len(arr)
ans = []
i = 0
while i < ln:
if arr[i] == "o":
if i + 2 < ln and arr[i + 1] == "n" and arr[i + 2] == "e":
if i - 1 >= 0 and arr[i - 1] == "o":
ans.append(i + 2)
else:
ans.append(i + 1)
i += 3
continue
if arr[i] == "t":
if i + 2 < ln and arr[i + 1] == "w" and arr[i + 2] == "o":
if i + 3 < ln and arr[i + 3] == "n":
ans.append(i + 3)
elif i - 1 >= 0 and arr[i - 1] == "t":
ans.append(i + 2)
else:
ans.append(i + 1)
i += 3
continue
i += 1
print(len(ans))
print(" ".join([str(x) for x in ans])) | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST ASSIGN VAR NUMBER WHILE VAR VAR IF VAR VAR STRING IF BIN_OP VAR NUMBER VAR VAR BIN_OP VAR NUMBER STRING VAR BIN_OP VAR NUMBER STRING IF BIN_OP VAR NUMBER NUMBER VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER IF VAR VAR STRING IF BIN_OP VAR NUMBER VAR VAR BIN_OP VAR NUMBER STRING VAR BIN_OP VAR NUMBER STRING IF BIN_OP VAR NUMBER VAR VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR BIN_OP VAR NUMBER IF BIN_OP VAR NUMBER NUMBER VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL STRING FUNC_CALL VAR VAR VAR VAR |
You are given a non-empty string s=s_1s_2... 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 β€ j β€ n-2), that s_{j}s_{j+1}s_{j+2}="one" or s_{j}s_{j+1}s_{j+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 β€ 10^4) β 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β
10^5. 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β
10^6.
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".
In the second example, answers are:
* "onetwonetwooneooonetwooo",
* "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". | t = int(input())
for _ in range(t):
s = input()
ind = []
n = len(s)
tot = 0
ans = set()
for i in range(n - 2):
if s[i : i + 3] == "one":
tot += 1
ans.add(i + 1)
if s[i : i + 3] == "two":
tot += 1
ans.add(i + 1)
for i in range(n - 4):
if s[i : i + 5] == "twone":
tot -= 1
ans.remove(i + 1)
ans.remove(i + 3)
ans.add(i + 2)
print(tot)
for i in ans:
print(i + 1, end=" ")
print()
continue
tt = []
oo = []
for i in range(0, n):
if s[i] == "t":
try:
tt.append(tt[-1] + 1)
except:
tt.append(1)
else:
tt.append(0)
if s[i] == "o":
try:
oo.append(tt[-1] + 1)
except:
oo.append(1)
else:
oo.append(0)
oo2 = [0] * n
ee = [0] * n
for i in range(n - 1, -1, -1):
if s[i] == "o":
try:
oo2[i] = 1 + oo[i + 1]
except:
oo2[i] = 1
else:
oo2[i] = 0
if s[i] == "e":
try:
ee[i] = 1 + ee[i + 1]
except:
ee[i] = 1
else:
ee[i] = 0
tot = 0
for i in range(n - 2):
if s[i : i + 3] == "one":
tot += min(oo[i], ee[i + 2])
elif s[i : i + 3] == "two":
tot += min(tt[i], oo2[i + 2])
st = 0
for i in range(n):
if i < n - 1:
if s[i : i + 2] == "tw":
st = 1
ind = i
if st and s[i] == "o":
st += 1
if st and s[i] != "o":
if i < n - 1:
if s[i : i + 2] == "ne" and st > 1:
ans = 0
ans += min(tt[ind], oo2[ind + 2])
ans += min(ee[i + 1], oo[i - 1])
if st - 1 < ans:
tot -= ans
tot += st - 1
st = 0
print(tot) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR VAR BIN_OP VAR NUMBER STRING VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR VAR BIN_OP VAR NUMBER STRING VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR VAR BIN_OP VAR NUMBER STRING VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR FOR VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR STRING EXPR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF VAR VAR STRING EXPR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER IF VAR VAR STRING ASSIGN VAR VAR BIN_OP NUMBER VAR BIN_OP VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER IF VAR VAR STRING ASSIGN VAR VAR BIN_OP NUMBER VAR BIN_OP VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR VAR BIN_OP VAR NUMBER STRING VAR FUNC_CALL VAR VAR VAR VAR BIN_OP VAR NUMBER IF VAR VAR BIN_OP VAR NUMBER STRING VAR FUNC_CALL VAR VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR BIN_OP VAR NUMBER IF VAR VAR BIN_OP VAR NUMBER STRING ASSIGN VAR NUMBER ASSIGN VAR VAR IF VAR VAR VAR STRING VAR NUMBER IF VAR VAR VAR STRING IF VAR BIN_OP VAR NUMBER IF VAR VAR BIN_OP VAR NUMBER STRING VAR NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR VAR VAR BIN_OP VAR NUMBER VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER IF BIN_OP VAR NUMBER VAR VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER EXPR FUNC_CALL VAR VAR |
You are given a non-empty string s=s_1s_2... 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 β€ j β€ n-2), that s_{j}s_{j+1}s_{j+2}="one" or s_{j}s_{j+1}s_{j+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 β€ 10^4) β 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β
10^5. 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β
10^6.
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".
In the second example, answers are:
* "onetwonetwooneooonetwooo",
* "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". | t = int(input())
l = []
for i in range(t):
l.append(str(input()))
for i in l:
r = 0
p = []
j = 0
while j < len(i) - 2:
if i[j : j + 5] == "twone":
r += 1
p.append(j + 3)
j += 5
elif i[j : j + 3] == "one":
r += 1
p.append(j + 2)
j += 3
elif i[j : j + 3] == "two":
r += 1
p.append(j + 2)
j += 3
else:
j += 1
if r == 0:
print(0)
print()
else:
print(r)
print(" ".join(map(str, p))) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR NUMBER WHILE VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR VAR BIN_OP VAR NUMBER STRING VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER IF VAR VAR BIN_OP VAR NUMBER STRING VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER IF VAR VAR BIN_OP VAR NUMBER STRING VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL STRING FUNC_CALL VAR VAR VAR |
You are given a non-empty string s=s_1s_2... 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 β€ j β€ n-2), that s_{j}s_{j+1}s_{j+2}="one" or s_{j}s_{j+1}s_{j+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 β€ 10^4) β 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β
10^5. 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β
10^6.
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".
In the second example, answers are:
* "onetwonetwooneooonetwooo",
* "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". | for _ in range(int(input())):
a = input()
a += "z"
b = [0] * len(a)
d = 1
while d < len(a) - 1:
d += 1
if a[d - 2] + a[d - 1] + a[d] in ["one", "two"]:
b[d - 1] += 1
for i in range(len(b) - 1):
if b[i] == 1 and b[i + 2] == 1:
b[i] = 0
b[i + 2] = 0
b[i + 1] = 1
print(b.count(1))
for i in range(len(b)):
if b[i] == 1:
print(i + 1, end=" ")
print() | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR STRING ASSIGN VAR BIN_OP LIST NUMBER FUNC_CALL VAR VAR ASSIGN VAR NUMBER WHILE VAR BIN_OP FUNC_CALL VAR VAR NUMBER VAR NUMBER IF BIN_OP BIN_OP VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER VAR VAR LIST STRING STRING VAR BIN_OP VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR VAR NUMBER VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR |
You are given a non-empty string s=s_1s_2... 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 β€ j β€ n-2), that s_{j}s_{j+1}s_{j+2}="one" or s_{j}s_{j+1}s_{j+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 β€ 10^4) β 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β
10^5. 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β
10^6.
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".
In the second example, answers are:
* "onetwonetwooneooonetwooo",
* "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". | N = int(input())
for _ in range(N):
s = list(input())
le = len(s)
res = []
b = 0
while b < le - 2:
if s[b : b + 3] == list("one") or s[b : b + 3] == list("two"):
if b + 4 < le and s[b : b + 5] == list("twone"):
res.append(b + 3)
s[b + 2] = "a"
b = b + 5
else:
res.append(b + 2)
s[b + 1] = "a"
b = b + 3
else:
b = b + 1
print(len(res))
print(" ".join(list(map(str, res)))) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST ASSIGN VAR NUMBER WHILE VAR BIN_OP VAR NUMBER IF VAR VAR BIN_OP VAR NUMBER FUNC_CALL VAR STRING VAR VAR BIN_OP VAR NUMBER FUNC_CALL VAR STRING IF BIN_OP VAR NUMBER VAR VAR VAR BIN_OP VAR NUMBER FUNC_CALL VAR STRING EXPR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER STRING ASSIGN VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER STRING ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL STRING FUNC_CALL VAR FUNC_CALL VAR VAR VAR |
You are given a non-empty string s=s_1s_2... 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 β€ j β€ n-2), that s_{j}s_{j+1}s_{j+2}="one" or s_{j}s_{j+1}s_{j+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 β€ 10^4) β 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β
10^5. 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β
10^6.
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".
In the second example, answers are:
* "onetwonetwooneooonetwooo",
* "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". | def f():
s = list(input())
delN = set()
delW = []
def checkOne(i):
if s[i - 1] != "o":
return
if s[i + 1] != "e":
return
delN.add(i)
def checkTwo(i):
if s[i - 1] != "t":
return
if s[i + 1] != "o":
return
delW.append(i)
l = len(s)
if l <= 2:
print(0)
print()
return
for i in range(1, l - 1):
if s[i] == "n":
checkOne(i)
if s[i] == "w":
checkTwo(i)
ans = []
for p in delW:
if p + 2 in delN:
ans.append(p + 1)
delN.discard(p + 2)
else:
ans.append(p)
for p in delN:
ans.append(p)
print(len(ans))
print(" ".join(str(s + 1) for s in ans))
t = int(input())
for i in range(t):
f() | FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST FUNC_DEF IF VAR BIN_OP VAR NUMBER STRING RETURN IF VAR BIN_OP VAR NUMBER STRING RETURN EXPR FUNC_CALL VAR VAR FUNC_DEF IF VAR BIN_OP VAR NUMBER STRING RETURN IF VAR BIN_OP VAR NUMBER STRING RETURN EXPR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR RETURN FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER IF VAR VAR STRING EXPR FUNC_CALL VAR VAR IF VAR VAR STRING EXPR FUNC_CALL VAR VAR ASSIGN VAR LIST FOR VAR VAR IF BIN_OP VAR NUMBER VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR FOR VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL STRING FUNC_CALL VAR BIN_OP VAR NUMBER VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR |
You are given a non-empty string s=s_1s_2... 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 β€ j β€ n-2), that s_{j}s_{j+1}s_{j+2}="one" or s_{j}s_{j+1}s_{j+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 β€ 10^4) β 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β
10^5. 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β
10^6.
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".
In the second example, answers are:
* "onetwonetwooneooonetwooo",
* "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". | for i in range(int(input())):
s = input()
k1 = 0
k2 = 0
count = 0
l = []
j = len(s) - 1
while j > 1:
if s[j - 2] == "o" and s[j - 1] == "n" and s[j] == "e":
j -= 3
count += 1
if j > 0 and s[j - 1] == "t" and s[j] == "w":
l.append(j + 2)
else:
l.append(j + 3)
elif s[j - 2] == "t" and s[j - 1] == "w" and s[j] == "o":
j -= 3
count += 1
l.append(j + 3)
else:
j -= 1
print(count)
print(*l) | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER WHILE VAR NUMBER IF VAR BIN_OP VAR NUMBER STRING VAR BIN_OP VAR NUMBER STRING VAR VAR STRING VAR NUMBER VAR NUMBER IF VAR NUMBER VAR BIN_OP VAR NUMBER STRING VAR VAR STRING EXPR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR BIN_OP VAR NUMBER STRING VAR BIN_OP VAR NUMBER STRING VAR VAR STRING VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR |
You are given a non-empty string s=s_1s_2... 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 β€ j β€ n-2), that s_{j}s_{j+1}s_{j+2}="one" or s_{j}s_{j+1}s_{j+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 β€ 10^4) β 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β
10^5. 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β
10^6.
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".
In the second example, answers are:
* "onetwonetwooneooonetwooo",
* "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". | t = int(input())
for i in range(t):
s = list(input())
cnt = 0
ind = []
for i in range(len(s)):
if i + 5 <= len(s):
if "".join(s[i : i + 5]) == "twone":
s[i + 2] = "#"
cnt += 1
ind.append(i + 3)
continue
if i + 2 < len(s) and s[i] + s[i + 1] + s[i + 2] == "one":
s[i + 1] = "#"
cnt += 1
ind.append(i + 2)
elif i + 2 < len(s) and s[i] + s[i + 1] + s[i + 2] == "two":
s[i + 1] = "#"
cnt += 1
ind.append(i + 2)
print(cnt)
print(*ind) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER FUNC_CALL VAR VAR IF FUNC_CALL STRING VAR VAR BIN_OP VAR NUMBER STRING ASSIGN VAR BIN_OP VAR NUMBER STRING VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER IF BIN_OP VAR NUMBER FUNC_CALL VAR VAR BIN_OP BIN_OP VAR VAR VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER STRING ASSIGN VAR BIN_OP VAR NUMBER STRING VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER IF BIN_OP VAR NUMBER FUNC_CALL VAR VAR BIN_OP BIN_OP VAR VAR VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER STRING ASSIGN VAR BIN_OP VAR NUMBER STRING VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR |
You are given a non-empty string s=s_1s_2... 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 β€ j β€ n-2), that s_{j}s_{j+1}s_{j+2}="one" or s_{j}s_{j+1}s_{j+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 β€ 10^4) β 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β
10^5. 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β
10^6.
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".
In the second example, answers are:
* "onetwonetwooneooonetwooo",
* "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". | import sys
def main():
for tc in range(int(input())):
s = list(input())
ans = []
for i in range(len(s) - 2):
x = "".join(s[i : i + 3])
y = ""
if i < len(s) - 4:
y = "".join(s[i + 2 : i + 5])
if x == "one":
ans.append(i + 2)
s[i + 1] = "#"
elif x == "two":
if y == "one":
ans.append(i + 3)
s[i + 2] = "#"
else:
ans.append(i + 2)
s[i + 1] = "#"
print(len(ans))
print(*ans)
get_array = lambda: list(map(int, sys.stdin.readline().split()))
get_ints = lambda: map(int, sys.stdin.readline().split())
input = lambda: sys.stdin.readline().strip()
main() | IMPORT FUNC_DEF FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL STRING VAR VAR BIN_OP VAR NUMBER ASSIGN VAR STRING IF VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL STRING VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER IF VAR STRING EXPR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER STRING IF VAR STRING IF VAR STRING EXPR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR |
You are given a non-empty string s=s_1s_2... 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 β€ j β€ n-2), that s_{j}s_{j+1}s_{j+2}="one" or s_{j}s_{j+1}s_{j+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 β€ 10^4) β 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β
10^5. 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β
10^6.
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".
In the second example, answers are:
* "onetwonetwooneooonetwooo",
* "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". | for _ in range(int(input())):
s = input()
a = []
for i in s:
a.append(i)
a.append(1)
a.append(1)
a.append(1)
n = len(s)
if n <= 2:
print(0)
print("")
continue
ans = []
for i in range(0, n - 2):
if [a[i], a[i + 1], a[i + 2]] == ["o", "n", "e"]:
ans.append(i + 2)
a[i + 1] = 1
elif [a[i], a[i + 1], a[i + 2]] == ["t", "w", "o"]:
if a[i + 3] == "n" and a[i + 4] == "e":
ans.append(i + 3)
a[i + 2] = 1
else:
ans.append(i + 2)
a[i + 1] = 1
print(len(ans))
for i in ans:
print(i, end=" ")
print() | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR STRING ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER IF LIST VAR VAR VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER LIST STRING STRING STRING EXPR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER NUMBER IF LIST VAR VAR VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER LIST STRING STRING STRING IF VAR BIN_OP VAR NUMBER STRING VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR FOR VAR VAR EXPR FUNC_CALL VAR VAR STRING EXPR FUNC_CALL VAR |
You are given a non-empty string s=s_1s_2... 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 β€ j β€ n-2), that s_{j}s_{j+1}s_{j+2}="one" or s_{j}s_{j+1}s_{j+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 β€ 10^4) β 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β
10^5. 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β
10^6.
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".
In the second example, answers are:
* "onetwonetwooneooonetwooo",
* "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". | import sys
input = lambda: sys.stdin.readline().rstrip("\r\n")
def oneLineArrayPrint(arr):
print(" ".join([str(x) for x in arr]))
t = int(input())
for _ in range(t):
s = list(input())
ans = []
for i in range(len(s)):
if "".join(s[i : i + 5]) == "twone":
ans.append(i + 3)
s[i + 2] = "z"
elif "".join(s[i : i + 3]) == "one":
ans.append(i + 2)
elif "".join(s[i : i + 3]) == "two":
ans.append(i + 2)
print(len(ans))
oneLineArrayPrint(ans) | IMPORT ASSIGN VAR FUNC_CALL FUNC_CALL VAR STRING FUNC_DEF EXPR FUNC_CALL VAR FUNC_CALL STRING FUNC_CALL VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF FUNC_CALL STRING VAR VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER STRING IF FUNC_CALL STRING VAR VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR BIN_OP VAR NUMBER IF FUNC_CALL STRING VAR VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR |
You are given a non-empty string s=s_1s_2... 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 β€ j β€ n-2), that s_{j}s_{j+1}s_{j+2}="one" or s_{j}s_{j+1}s_{j+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 β€ 10^4) β 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β
10^5. 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β
10^6.
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".
In the second example, answers are:
* "onetwonetwooneooonetwooo",
* "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". | def make_liked(s):
i = 0
remove = []
while i < len(s) - 2:
if (
i < len(s) - 4
and s[i] == "t"
and s[i + 1] == "w"
and s[i + 2] == "o"
and s[i + 3] == "n"
and s[i + 4] == "e"
):
remove.append(i + 3)
i += 4
continue
if s[i] == "o" and s[i + 1] == "n" and s[i + 2] == "e":
remove.append(i + 2)
elif s[i] == "t" and s[i + 1] == "w" and s[i + 2] == "o":
remove.append(i + 2)
i += 1
print(len(remove))
print(*remove)
t = int(input())
for i in range(t):
s = input()
make_liked(s) | FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR LIST WHILE VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR BIN_OP FUNC_CALL VAR VAR NUMBER VAR VAR STRING VAR BIN_OP VAR NUMBER STRING VAR BIN_OP VAR NUMBER STRING VAR BIN_OP VAR NUMBER STRING VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER IF VAR VAR STRING VAR BIN_OP VAR NUMBER STRING VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR VAR STRING VAR BIN_OP VAR NUMBER STRING VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR EXPR FUNC_CALL VAR VAR |
You are given a non-empty string s=s_1s_2... 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 β€ j β€ n-2), that s_{j}s_{j+1}s_{j+2}="one" or s_{j}s_{j+1}s_{j+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 β€ 10^4) β 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β
10^5. 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β
10^6.
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".
In the second example, answers are:
* "onetwonetwooneooonetwooo",
* "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". | t = int(input())
for i in range(t):
s = input()
n = len(s)
ans = [""] * n
ansn = 0
i = 0
while i < n:
if i < n - 2:
if i < n - 4 and s[i : i + 5] == "twone":
ans[i + 2] = str(i + 3) + " "
ansn += 1
i += 4
elif i < n - 2 and (s[i : i + 3] == "one" or s[i : i + 3] == "two"):
ans[i + 1] = str(i + 2) + " "
ansn += 1
i += 2
i += 1
print(ansn)
print("".join(ans)) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST STRING VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR IF VAR BIN_OP VAR NUMBER IF VAR BIN_OP VAR NUMBER VAR VAR BIN_OP VAR NUMBER STRING ASSIGN VAR BIN_OP VAR NUMBER BIN_OP FUNC_CALL VAR BIN_OP VAR NUMBER STRING VAR NUMBER VAR NUMBER IF VAR BIN_OP VAR NUMBER VAR VAR BIN_OP VAR NUMBER STRING VAR VAR BIN_OP VAR NUMBER STRING ASSIGN VAR BIN_OP VAR NUMBER BIN_OP FUNC_CALL VAR BIN_OP VAR NUMBER STRING VAR NUMBER VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL STRING VAR |
You are given a non-empty string s=s_1s_2... 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 β€ j β€ n-2), that s_{j}s_{j+1}s_{j+2}="one" or s_{j}s_{j+1}s_{j+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 β€ 10^4) β 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β
10^5. 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β
10^6.
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".
In the second example, answers are:
* "onetwonetwooneooonetwooo",
* "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". | t = int(input())
for i in range(t):
s = input()
l = len(s)
rem = []
ans = 0
skip = 0
for j in range(l - 2):
if skip > 0:
skip -= 1
continue
if j <= l - 5 and s[j : j + 5] == "twone":
ans += 1
rem.append(j + 3)
skip = 4
elif s[j : j + 3] == "two":
ans += 1
rem.append(j + 2)
elif s[j : j + 3] == "one":
ans += 1
rem.append(j + 2)
print(ans)
if ans == 0:
print()
else:
for j in rem:
print(j, end=" ")
print() | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR NUMBER VAR NUMBER IF VAR BIN_OP VAR NUMBER VAR VAR BIN_OP VAR NUMBER STRING VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER IF VAR VAR BIN_OP VAR NUMBER STRING VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR VAR BIN_OP VAR NUMBER STRING VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR FOR VAR VAR EXPR FUNC_CALL VAR VAR STRING EXPR FUNC_CALL VAR |
You are given a non-empty string s=s_1s_2... 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 β€ j β€ n-2), that s_{j}s_{j+1}s_{j+2}="one" or s_{j}s_{j+1}s_{j+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 β€ 10^4) β 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β
10^5. 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β
10^6.
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".
In the second example, answers are:
* "onetwonetwooneooonetwooo",
* "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". | from sys import stdin
def input():
return int(stdin.readline())
def minput():
return map(int, stdin.readline().split())
def linput():
return list(map(int, stdin.readline().split()))
for _ in range(input()):
us = set()
s = stdin.readline()
m = len(s) - 2
i = 0
while i < m:
if s[i] == "t":
if s[i + 1] == "w" and s[i + 2] == "o":
if i < m - 2 and s[i + 3] == "n" and s[i + 4] == "e":
us.add(i + 2)
else:
us.add(i + 1)
i += 2
elif s[i] == "o":
if s[i + 1] == "n" and s[i + 2] == "e":
us.add(i + 1)
i += 2
i += 1
print(len(us))
for u in us:
print(u + 1, end=" ")
print() | FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR IF VAR VAR STRING IF VAR BIN_OP VAR NUMBER STRING VAR BIN_OP VAR NUMBER STRING IF VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER STRING VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER IF VAR VAR STRING IF VAR BIN_OP VAR NUMBER STRING VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR FOR VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR |
You are given a non-empty string s=s_1s_2... 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 β€ j β€ n-2), that s_{j}s_{j+1}s_{j+2}="one" or s_{j}s_{j+1}s_{j+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 β€ 10^4) β 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β
10^5. 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β
10^6.
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".
In the second example, answers are:
* "onetwonetwooneooonetwooo",
* "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". | t = int(input())
for i in range(0, t):
count = 0
s = []
ignoreOne = False
emptyS = True
line = input()
for f in range(0, len(line)):
if line[f] == "t":
if line[f : f + 5] == "twone":
s.append(str(f + 3))
count = count + 1
ignoreOne = True
elif line[f : f + 3] == "two":
s.append(str(f + 2))
count = count + 1
if line[f] == "o":
if line[f : f + 3] == "one":
if ignoreOne == True:
ignoreOne = False
else:
count = count + 1
s.append(str(f + 2))
print(count)
print(" ".join(s)) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR IF VAR VAR STRING IF VAR VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER IF VAR VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF VAR VAR STRING IF VAR VAR BIN_OP VAR NUMBER STRING IF VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL STRING VAR |
You are given a non-empty string s=s_1s_2... 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 β€ j β€ n-2), that s_{j}s_{j+1}s_{j+2}="one" or s_{j}s_{j+1}s_{j+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 β€ 10^4) β 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β
10^5. 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β
10^6.
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".
In the second example, answers are:
* "onetwonetwooneooonetwooo",
* "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". | for _ in range(int(input())):
s = input()
l = []
for i in range(len(s) - 2):
if s[i] == "o" and s[i + 1] == "n" and s[i + 2] == "e":
if len(l) > 0 and l[-1][1] and i - 1 == l[-1][0]:
l.pop()
l.append([i, False])
else:
l.append([i + 1, False])
elif s[i] == "t" and s[i + 1] == "w" and s[i + 2] == "o":
l.append([i + 1, True])
print(len(l))
if len(l) > 0:
for i in l:
print(i[0] + 1, end=" ")
print() | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR VAR STRING VAR BIN_OP VAR NUMBER STRING VAR BIN_OP VAR NUMBER STRING IF FUNC_CALL VAR VAR NUMBER VAR NUMBER NUMBER BIN_OP VAR NUMBER VAR NUMBER NUMBER EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR LIST VAR NUMBER EXPR FUNC_CALL VAR LIST BIN_OP VAR NUMBER NUMBER IF VAR VAR STRING VAR BIN_OP VAR NUMBER STRING VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR LIST BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR NUMBER FOR VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER STRING EXPR FUNC_CALL VAR |
You are given a non-empty string s=s_1s_2... 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 β€ j β€ n-2), that s_{j}s_{j+1}s_{j+2}="one" or s_{j}s_{j+1}s_{j+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 β€ 10^4) β 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β
10^5. 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β
10^6.
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".
In the second example, answers are:
* "onetwonetwooneooonetwooo",
* "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". | for i in range(int(input())):
seg = list(input())
ind = []
i = 0
while i < len(seg) - 2:
if seg[i] not in ("t", "o"):
i += 1
elif seg[i : i + 5] == ["t", "w", "o", "n", "e"]:
ind += [i + 3]
i += 5
elif seg[i : i + 3] == ["t", "w", "o"] or seg[i : i + 3] == ["o", "n", "e"]:
ind += [i + 2]
i += 3
else:
i += 1
print(len(ind))
print(*ind) | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER WHILE VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR VAR STRING STRING VAR NUMBER IF VAR VAR BIN_OP VAR NUMBER LIST STRING STRING STRING STRING STRING VAR LIST BIN_OP VAR NUMBER VAR NUMBER IF VAR VAR BIN_OP VAR NUMBER LIST STRING STRING STRING VAR VAR BIN_OP VAR NUMBER LIST STRING STRING STRING VAR LIST BIN_OP VAR NUMBER VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR |
You are given a non-empty string s=s_1s_2... 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 β€ j β€ n-2), that s_{j}s_{j+1}s_{j+2}="one" or s_{j}s_{j+1}s_{j+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 β€ 10^4) β 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β
10^5. 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β
10^6.
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".
In the second example, answers are:
* "onetwonetwooneooonetwooo",
* "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". | import sys
input = sys.stdin.readline
for _ in range(int(input())):
s = input()
n = len(s)
check = [0] * n
ans = []
for i in range(n):
if s[i : i + 5] == "twone":
ans.append(str(i + 3))
for j in range(i, i + 5):
check[j] = 1
for i in range(n):
if check[i]:
continue
if s[i : i + 3] == "one":
ans.append(str(i + 2))
if s[i : i + 3] == "two":
ans.append(str(i + 2))
print(s.count("one") + s.count("two") - s.count("twone"))
print(" ".join(ans)) | IMPORT ASSIGN VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR IF VAR VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER ASSIGN VAR VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR IF VAR VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP FUNC_CALL VAR STRING FUNC_CALL VAR STRING FUNC_CALL VAR STRING EXPR FUNC_CALL VAR FUNC_CALL STRING VAR |
You are given a non-empty string s=s_1s_2... 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 β€ j β€ n-2), that s_{j}s_{j+1}s_{j+2}="one" or s_{j}s_{j+1}s_{j+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 β€ 10^4) β 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β
10^5. 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β
10^6.
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".
In the second example, answers are:
* "onetwonetwooneooonetwooo",
* "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". | a = int(input())
for x in range(a):
b = input()
c = len(b)
d = list(b)
k = 0
h = []
if c == 1 or c == 2:
print(0)
print()
elif c == 3:
if d[0] == "o":
if d[1] == "n":
if d[2] == "e":
k += 1
d[0] = "@"
h.append(1)
elif d[2] == "o":
if d[1] == "w":
if d[0] == "t":
k += 1
d[2] = "@"
h.append(3)
print(k)
print(*h)
else:
for y in range(c):
if d[y] == "o":
if y == 0 or y == 1:
if d[y + 1] == "n":
if d[y + 2] == "e":
k += 1
d[y + 1] = "@"
h.append(y + 2)
elif y == c - 2 or y == c - 1:
if d[y - 1] == "w":
if d[y - 2] == "t":
k += 1
d[y - 1] = "@"
h.append(y)
elif (d[y + 1] == "n" and d[y + 2] == "e") and (
d[y - 1] == "w" and d[y - 2] == "t"
):
k += 1
d[y] = "@"
h.append(y + 1)
elif d[y + 1] == "n" and d[y + 2] == "e":
k += 1
d[y + 1] == "@"
h.append(y + 2)
elif d[y - 1] == "w" and d[y - 2] == "t":
k += 1
d[y - 1] == "@"
h.append(y)
print(k)
print(*h) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR LIST IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR IF VAR NUMBER IF VAR NUMBER STRING IF VAR NUMBER STRING IF VAR NUMBER STRING VAR NUMBER ASSIGN VAR NUMBER STRING EXPR FUNC_CALL VAR NUMBER IF VAR NUMBER STRING IF VAR NUMBER STRING IF VAR NUMBER STRING VAR NUMBER ASSIGN VAR NUMBER STRING EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING IF VAR NUMBER VAR NUMBER IF VAR BIN_OP VAR NUMBER STRING IF VAR BIN_OP VAR NUMBER STRING VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER IF VAR BIN_OP VAR NUMBER STRING IF VAR BIN_OP VAR NUMBER STRING VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR VAR IF VAR BIN_OP VAR NUMBER STRING VAR BIN_OP VAR NUMBER STRING VAR BIN_OP VAR NUMBER STRING VAR BIN_OP VAR NUMBER STRING VAR NUMBER ASSIGN VAR VAR STRING EXPR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR BIN_OP VAR NUMBER STRING VAR BIN_OP VAR NUMBER STRING VAR NUMBER EXPR VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR BIN_OP VAR NUMBER STRING VAR BIN_OP VAR NUMBER STRING VAR NUMBER EXPR VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR |
You are given a non-empty string s=s_1s_2... 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 β€ j β€ n-2), that s_{j}s_{j+1}s_{j+2}="one" or s_{j}s_{j+1}s_{j+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 β€ 10^4) β 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β
10^5. 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β
10^6.
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".
In the second example, answers are:
* "onetwonetwooneooonetwooo",
* "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". | import sys
reader = (s.rstrip() for s in sys.stdin)
input = reader.__next__
def solve():
s = input()
ans = []
n = len(s)
used = [0] * n
for i in range(n):
if i <= n - 5 and s[i] == "t" and s[i : i + 5] == "twone":
ans.append(i + 3)
used[i + 2] = 1
used[i] = 1
if i <= n - 3 and not used[i] and s[i] == "t" and s[i : i + 3] == "two":
ans.append(i + 2)
if i <= n - 3 and not used[i] and s[i] == "o" and s[i : i + 3] == "one":
ans.append(i + 2)
print(len(ans))
print(*ans)
t = int(input())
for i in range(t):
solve() | IMPORT ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR VAR IF VAR BIN_OP VAR NUMBER VAR VAR STRING VAR VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR VAR NUMBER IF VAR BIN_OP VAR NUMBER VAR VAR VAR VAR STRING VAR VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR BIN_OP VAR NUMBER VAR VAR VAR VAR STRING VAR VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR |
You are given a non-empty string s=s_1s_2... 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 β€ j β€ n-2), that s_{j}s_{j+1}s_{j+2}="one" or s_{j}s_{j+1}s_{j+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 β€ 10^4) β 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β
10^5. 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β
10^6.
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".
In the second example, answers are:
* "onetwonetwooneooonetwooo",
* "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". | t = int(input())
while t:
t -= 1
a = input()
n = len(a)
ans = []
for i in range(n):
if a[i] == "o":
if i < n - 2 and a[i + 1] == "n" and a[i + 2] == "e":
if i > 0 and a[i - 1] == "o":
ans += [i + 2]
else:
ans += [i + 1]
elif i - 2 >= 0 and a[i - 1] == "w" and a[i - 2] == "t":
if i < n - 1 and a[i + 1] == "o":
ans += [i]
else:
ans += [i + 1]
print(len(ans))
if len(ans):
print(*ans)
else:
print() | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING IF VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER STRING VAR BIN_OP VAR NUMBER STRING IF VAR NUMBER VAR BIN_OP VAR NUMBER STRING VAR LIST BIN_OP VAR NUMBER VAR LIST BIN_OP VAR NUMBER IF BIN_OP VAR NUMBER NUMBER VAR BIN_OP VAR NUMBER STRING VAR BIN_OP VAR NUMBER STRING IF VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER STRING VAR LIST VAR VAR LIST BIN_OP VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR |
You are given a non-empty string s=s_1s_2... 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 β€ j β€ n-2), that s_{j}s_{j+1}s_{j+2}="one" or s_{j}s_{j+1}s_{j+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 β€ 10^4) β 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β
10^5. 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β
10^6.
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".
In the second example, answers are:
* "onetwonetwooneooonetwooo",
* "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". | for _ in range(int(input())):
s = input()
s = s.replace("twone", "tw?ne")
s = s.replace("one", "o?e")
s = s.replace("two", "t?o")
ans = 0
ans_i = []
for i in range(len(s)):
if s[i] == "?":
ans += 1
ans_i.append(i + 1)
print(ans)
if len(ans_i) != 0:
print(*ans_i) | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING STRING ASSIGN VAR FUNC_CALL VAR STRING STRING ASSIGN VAR FUNC_CALL VAR STRING STRING ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR VAR |
You are given a non-empty string s=s_1s_2... 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 β€ j β€ n-2), that s_{j}s_{j+1}s_{j+2}="one" or s_{j}s_{j+1}s_{j+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 β€ 10^4) β 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β
10^5. 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β
10^6.
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".
In the second example, answers are:
* "onetwonetwooneooonetwooo",
* "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". | def solve():
S = input()
l = 0
ans = []
while l < len(S) - 2:
if S[l] == "o":
if S[l + 1] == "n" and S[l + 2] == "e":
ans.append(l + 1)
l += 3
else:
l += 1
elif S[l] == "t":
if S[l + 1] == "w" and S[l + 2] == "o":
if l < len(S) - 4 and S[l + 3] == "n" and S[l + 4] == "e":
ans.append(l + 2)
l += 5
else:
ans.append(l + 1)
l += 3
else:
l += 1
else:
l += 1
if ans == []:
print(0)
print()
else:
print(len(ans))
print(" ".join(map(lambda x: str(x + 1), ans)))
def check():
T = ""
for i, s in enumerate(S):
if i in ans:
continue
else:
T += s
for a, b, c in zip(T, T[1:], T[2:]):
if a + b + c in {"one", "two"}:
print("error")
assert 1 == 2
T = int(input())
for _ in range(T):
solve() | FUNC_DEF ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR LIST WHILE VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR VAR STRING IF VAR BIN_OP VAR NUMBER STRING VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER VAR NUMBER IF VAR VAR STRING IF VAR BIN_OP VAR NUMBER STRING VAR BIN_OP VAR NUMBER STRING IF VAR BIN_OP FUNC_CALL VAR VAR NUMBER VAR BIN_OP VAR NUMBER STRING VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER IF VAR LIST EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL STRING FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR FUNC_DEF ASSIGN VAR STRING FOR VAR VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR FOR VAR VAR VAR FUNC_CALL VAR VAR VAR NUMBER VAR NUMBER IF BIN_OP BIN_OP VAR VAR VAR STRING STRING EXPR FUNC_CALL VAR STRING NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR |
You are given a non-empty string s=s_1s_2... 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 β€ j β€ n-2), that s_{j}s_{j+1}s_{j+2}="one" or s_{j}s_{j+1}s_{j+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 β€ 10^4) β 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β
10^5. 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β
10^6.
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".
In the second example, answers are:
* "onetwonetwooneooonetwooo",
* "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". | t = int(input())
while t:
res = []
s = input()
i = 0
n = len(s)
while i < n:
if i + 4 < n:
st = s[i] + s[i + 1] + s[i + 2] + s[i + 3] + s[i + 4]
if st == "twone":
res.append(i + 2 + 1)
i = i + 5
else:
st = s[i] + s[i + 1] + s[i + 2]
if st == "two":
res.append(i + 1 + 1)
i = i + 3
elif st == "one":
res.append(i + 1 + 1)
i = i + 3
else:
i += 1
elif i + 2 < n:
st = s[i] + s[i + 1] + s[i + 2]
if st == "two":
res.append(i + 1 + 1)
i = i + 3
elif st == "one":
res.append(i + 1 + 1)
i = i + 3
else:
i += 1
else:
i += 1
print(len(res))
print(*res)
t -= 1 | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR WHILE VAR VAR IF BIN_OP VAR NUMBER VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP BIN_OP VAR VAR VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER IF VAR STRING EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER IF VAR STRING EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF VAR STRING EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER VAR NUMBER IF BIN_OP VAR NUMBER VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER IF VAR STRING EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF VAR STRING EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR NUMBER |
You are given a non-empty string s=s_1s_2... 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 β€ j β€ n-2), that s_{j}s_{j+1}s_{j+2}="one" or s_{j}s_{j+1}s_{j+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 β€ 10^4) β 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β
10^5. 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β
10^6.
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".
In the second example, answers are:
* "onetwonetwooneooonetwooo",
* "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". | import sys
input = sys.stdin.readline
inf = 100000000000000000
mod = 998244353
for CASES in range(int(input())):
S = input().strip()
if len(S) < 3:
print(0)
print()
continue
A = [S[0], S[1]]
ANS = []
for i in range(2, len(S)):
if S[i] == "e" and A[-1] == "n" and A[-2] == "o":
ANS.append(i)
A.pop()
A.append(S[i])
elif S[i] == "o" and A[-1] == "w" and A[-2] == "t":
if i + 2 < len(S) and S[i + 1] == "n" and S[i + 2] == "e":
ANS.append(i + 1)
else:
ANS.append(i)
A.pop()
A.append(S[i])
else:
A.append(S[i])
print(len(ANS))
print(*ANS) | IMPORT ASSIGN VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR IF FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR ASSIGN VAR LIST VAR NUMBER VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR IF VAR VAR STRING VAR NUMBER STRING VAR NUMBER STRING EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR VAR VAR IF VAR VAR STRING VAR NUMBER STRING VAR NUMBER STRING IF BIN_OP VAR NUMBER FUNC_CALL VAR VAR VAR BIN_OP VAR NUMBER STRING VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR |
You are given a non-empty string s=s_1s_2... 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 β€ j β€ n-2), that s_{j}s_{j+1}s_{j+2}="one" or s_{j}s_{j+1}s_{j+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 β€ 10^4) β 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β
10^5. 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β
10^6.
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".
In the second example, answers are:
* "onetwonetwooneooonetwooo",
* "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". | def twelve(s):
dellst = []
i = 0
while i <= len(s) - 3:
if s[i : i + 3] == "one":
dellst += [i + 2]
i += 3
elif s[i : i + 3] == "two":
if i <= len(s) - 5:
if s[i : i + 5] == "twone":
dellst += [i + 3]
i += 5
else:
dellst += [i + 2]
i += 3
else:
dellst += [i + 2]
i += 3
else:
i += 1
return dellst
m = int(input())
for i in range(m):
s = input()
k = twelve(s)
print(len(k))
print(*k) | FUNC_DEF ASSIGN VAR LIST ASSIGN VAR NUMBER WHILE VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR VAR BIN_OP VAR NUMBER STRING VAR LIST BIN_OP VAR NUMBER VAR NUMBER IF VAR VAR BIN_OP VAR NUMBER STRING IF VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR VAR BIN_OP VAR NUMBER STRING VAR LIST BIN_OP VAR NUMBER VAR NUMBER VAR LIST BIN_OP VAR NUMBER VAR NUMBER VAR LIST BIN_OP VAR NUMBER VAR NUMBER VAR NUMBER RETURN VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR |
You are given a non-empty string s=s_1s_2... 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 β€ j β€ n-2), that s_{j}s_{j+1}s_{j+2}="one" or s_{j}s_{j+1}s_{j+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 β€ 10^4) β 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β
10^5. 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β
10^6.
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".
In the second example, answers are:
* "onetwonetwooneooonetwooo",
* "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". | out = []
for i in range(int(input())):
s, ans = list(input()), []
for j in range(2, len(s)):
tem = "".join(s[j - 2 : j + 1])
if tem == "one":
ans.append(str(j))
s[j - 1] = "o"
elif tem == "two":
if j < len(s) - 2 and "".join(s[j : j + 3]) == "one":
s[j] = "n"
ans.append(str(j + 1))
else:
s[j - 1] = "n"
ans.append(str(j))
out.append(str(len(ans)))
out.append(" ".join(ans))
print("\n".join(out)) | ASSIGN VAR LIST FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR LIST FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL STRING VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER IF VAR STRING EXPR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR NUMBER STRING IF VAR STRING IF VAR BIN_OP FUNC_CALL VAR VAR NUMBER FUNC_CALL STRING VAR VAR BIN_OP VAR NUMBER STRING ASSIGN VAR VAR STRING EXPR FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL STRING VAR EXPR FUNC_CALL VAR FUNC_CALL STRING VAR |
You are given a non-empty string s=s_1s_2... 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 β€ j β€ n-2), that s_{j}s_{j+1}s_{j+2}="one" or s_{j}s_{j+1}s_{j+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 β€ 10^4) β 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β
10^5. 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β
10^6.
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".
In the second example, answers are:
* "onetwonetwooneooonetwooo",
* "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". | for tests in range(int(input())):
A = input()
num = 0
x = []
for s in range(len(A) - 2):
if A[s : s + 3] == "one":
if num == 0 or x[-1] != s + 1:
x.append(s + 2)
num += 1
elif A[s : s + 3] == "two":
if A[s : s + 5] == "twone":
x.append(s + 3)
else:
x.append(s + 2)
num += 1
print(num)
if num == 0:
print("")
else:
print(" ".join(str(k) for k in x)) | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR VAR BIN_OP VAR NUMBER STRING IF VAR NUMBER VAR NUMBER BIN_OP VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER IF VAR VAR BIN_OP VAR NUMBER STRING IF VAR VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR FUNC_CALL STRING FUNC_CALL VAR VAR VAR VAR |
You are given a non-empty string s=s_1s_2... 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 β€ j β€ n-2), that s_{j}s_{j+1}s_{j+2}="one" or s_{j}s_{j+1}s_{j+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 β€ 10^4) β 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β
10^5. 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β
10^6.
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".
In the second example, answers are:
* "onetwonetwooneooonetwooo",
* "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". | def test(s):
n = len(s)
d = set()
for i in range(n - 4):
if s[i : i + 5] == "twone":
d.add(i + 2 + 1)
for i in range(n - 2):
if (
s[i : i + 3] == "two"
and i + 2 + 1 not in d
or s[i : i + 3] == "one"
and i + 1 not in d
):
d.add(i + 1 + 1)
print(len(d))
print(" ".join(list(map(str, d))))
for i in range(int(input())):
test(input()) | FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR VAR BIN_OP VAR NUMBER STRING BIN_OP BIN_OP VAR NUMBER NUMBER VAR VAR VAR BIN_OP VAR NUMBER STRING BIN_OP VAR NUMBER VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL STRING FUNC_CALL VAR FUNC_CALL VAR VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_CALL VAR |
You are given a non-empty string s=s_1s_2... 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 β€ j β€ n-2), that s_{j}s_{j+1}s_{j+2}="one" or s_{j}s_{j+1}s_{j+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 β€ 10^4) β 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β
10^5. 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β
10^6.
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".
In the second example, answers are:
* "onetwonetwooneooonetwooo",
* "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". | import sys
readline = sys.stdin.readline
T = int(readline())
Ans = [None] * T
so = ord("o")
sn = ord("n")
se = ord("e")
st = ord("t")
sw = ord("w")
inf = 10**9 + 7
for qu in range(T):
S = list(map(ord, readline().strip()))
N = len(S)
Ans = []
for i in range(2, N - 2):
s = S[i]
if s != so:
continue
if S[i - 2] == st and S[i - 1] == sw and S[i + 1] == sn and S[i + 2] == se:
S[i] = 0
Ans.append(i + 1)
for i in range(1, N - 1):
s = S[i]
if S[i - 1] == so and S[i] == sn and S[i + 1] == se:
Ans.append(i + 1)
if S[i - 1] == st and S[i] == sw and S[i + 1] == so:
Ans.append(i + 1)
sys.stdout.write(str(len(Ans)))
sys.stdout.write("\n")
sys.stdout.write(" ".join(map(str, Ans)))
sys.stdout.write("\n") | IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NONE VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR VAR VAR IF VAR VAR IF VAR BIN_OP VAR NUMBER VAR VAR BIN_OP VAR NUMBER VAR VAR BIN_OP VAR NUMBER VAR VAR BIN_OP VAR NUMBER VAR ASSIGN VAR VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR VAR VAR IF VAR BIN_OP VAR NUMBER VAR VAR VAR VAR VAR BIN_OP VAR NUMBER VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR BIN_OP VAR NUMBER VAR VAR VAR VAR VAR BIN_OP VAR NUMBER VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR FUNC_CALL STRING FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR STRING |
You are given a non-empty string s=s_1s_2... 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 β€ j β€ n-2), that s_{j}s_{j+1}s_{j+2}="one" or s_{j}s_{j+1}s_{j+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 β€ 10^4) β 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β
10^5. 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β
10^6.
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".
In the second example, answers are:
* "onetwonetwooneooonetwooo",
* "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". | t = int(input())
for i in range(t):
s = str(input())
arr = []
s += "111"
j = 0
while j <= len(s) - 2:
q = s[j : j + 3]
p = s[j + 2 : j + 5]
if q == "one":
arr.append(j + 2)
j += 3
elif q == "two":
if p == "one":
arr.append(j + 3)
j += 5
else:
arr.append(j + 2)
j += 3
else:
j += 1
print(len(arr))
for j in range(len(arr)):
print(arr[j], end=" ")
print() | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST VAR STRING ASSIGN VAR NUMBER WHILE VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER IF VAR STRING EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER IF VAR STRING IF VAR STRING EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR STRING EXPR FUNC_CALL VAR |
You are given a non-empty string s=s_1s_2... 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 β€ j β€ n-2), that s_{j}s_{j+1}s_{j+2}="one" or s_{j}s_{j+1}s_{j+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 β€ 10^4) β 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β
10^5. 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β
10^6.
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".
In the second example, answers are:
* "onetwonetwooneooonetwooo",
* "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". | for _ in range(int(input())):
l = list(input())
ans = 0
for t in range(2, len(l) - 2):
if l[t] == "o" and l[t - 1] == "w" and l[t - 2] == "t":
if l[t + 1] == "n" and l[t + 2] == "e":
ans += 1
l[t] = "1"
for t in range(1, len(l) - 1):
if l[t] == "n" and l[t - 1] == "o" and l[t + 1] == "e":
ans += 1
l[t] = "1"
if l[t] == "w" and l[t - 1] == "t" and l[t + 1] == "o":
ans += 1
l[t] = "1"
print(ans)
for t in range(len(l)):
if l[t] == "1":
print(t + 1, end=" ")
print() | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR VAR STRING VAR BIN_OP VAR NUMBER STRING VAR BIN_OP VAR NUMBER STRING IF VAR BIN_OP VAR NUMBER STRING VAR BIN_OP VAR NUMBER STRING VAR NUMBER ASSIGN VAR VAR STRING FOR VAR FUNC_CALL VAR NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR VAR STRING VAR BIN_OP VAR NUMBER STRING VAR BIN_OP VAR NUMBER STRING VAR NUMBER ASSIGN VAR VAR STRING IF VAR VAR STRING VAR BIN_OP VAR NUMBER STRING VAR BIN_OP VAR NUMBER STRING VAR NUMBER ASSIGN VAR VAR STRING EXPR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR STRING EXPR FUNC_CALL VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR |
You are given a non-empty string s=s_1s_2... 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 β€ j β€ n-2), that s_{j}s_{j+1}s_{j+2}="one" or s_{j}s_{j+1}s_{j+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 β€ 10^4) β 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β
10^5. 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β
10^6.
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".
In the second example, answers are:
* "onetwonetwooneooonetwooo",
* "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". | t = int(input())
for i in range(t):
s = input()
ss = []
c = 0
j = 0
while j < len(s) - 2:
if s[j : j + 5] == "twone":
ss.append(j + 3)
c = c + 1
j = j + 5
elif s[j : j + 3] == "two":
ss.append(j + 2)
c = c + 1
j = j + 3
elif s[j : j + 3] == "one":
ss.append(j + 2)
c = c + 1
j = j + 3
else:
j = j + 1
print(c)
print(" ".join(map(str, ss))) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF VAR VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF VAR VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL STRING FUNC_CALL VAR VAR VAR |
You are given a non-empty string s=s_1s_2... 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 β€ j β€ n-2), that s_{j}s_{j+1}s_{j+2}="one" or s_{j}s_{j+1}s_{j+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 β€ 10^4) β 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β
10^5. 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β
10^6.
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".
In the second example, answers are:
* "onetwonetwooneooonetwooo",
* "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". | for _ in [0] * int(input()):
s = input()
ans = ""
NumAns = 0
i = 0
N = len(s)
while i <= N - 3:
if s[i : i + 3] == "one":
NumAns += 1
ans += str(i + 1 + 1) + " "
i = i + 3
elif s[i : i + 3] == "two":
if i + 5 <= N and s[i : i + 5] == "twone":
ans += str(i + 2 + 1) + " "
i = i + 5
NumAns += 1
else:
ans += str(i + 1 + 1) + " "
i = i + 3
NumAns += 1
else:
i += 1
print(NumAns)
if NumAns > 0:
print(ans[:-1]) | FOR VAR BIN_OP LIST NUMBER FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR STRING ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR WHILE VAR BIN_OP VAR NUMBER IF VAR VAR BIN_OP VAR NUMBER STRING VAR NUMBER VAR BIN_OP FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER NUMBER STRING ASSIGN VAR BIN_OP VAR NUMBER IF VAR VAR BIN_OP VAR NUMBER STRING IF BIN_OP VAR NUMBER VAR VAR VAR BIN_OP VAR NUMBER STRING VAR BIN_OP FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER NUMBER STRING ASSIGN VAR BIN_OP VAR NUMBER VAR NUMBER VAR BIN_OP FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER NUMBER STRING ASSIGN VAR BIN_OP VAR NUMBER VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR VAR NUMBER |
You are given a non-empty string s=s_1s_2... 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 β€ j β€ n-2), that s_{j}s_{j+1}s_{j+2}="one" or s_{j}s_{j+1}s_{j+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 β€ 10^4) β 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β
10^5. 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β
10^6.
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".
In the second example, answers are:
* "onetwonetwooneooonetwooo",
* "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". | n = int(input())
for i in range(n):
z = input() + " "
x = len(z)
a = []
q = 0
w = 0
while q < x - 2:
if z[q : q + 3] == "one":
a.append(q + 2)
q += 2
w += 1
elif z[q : q + 3] == "two":
if z[q + 2 : q + 5] == "one":
a.append(q + 3)
else:
a.append(q + 2)
q += 2
w += 1
q += 1
print(w)
for i in range(w):
print(a[i], end=" ")
print() | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR BIN_OP VAR NUMBER IF VAR VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER VAR NUMBER IF VAR VAR BIN_OP VAR NUMBER STRING IF VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR STRING EXPR FUNC_CALL VAR |
You are given a non-empty string s=s_1s_2... 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 β€ j β€ n-2), that s_{j}s_{j+1}s_{j+2}="one" or s_{j}s_{j+1}s_{j+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 β€ 10^4) β 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β
10^5. 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β
10^6.
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".
In the second example, answers are:
* "onetwonetwooneooonetwooo",
* "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". | for _ in range(int(input())):
s = input()
result, c, j = list(), 0, 0
while j < len(s) - 2:
if s[j : j + 5] == "twone":
result.append(j + 3)
c += 1
j += 5
elif s[j : j + 3] == "two":
result.append(j + 2)
c += 1
j += 3
elif s[j : j + 3] == "one":
result.append(j + 2)
c += 1
j += 3
else:
j += 1
print(c)
print(" ".join(map(str, result))) | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR NUMBER NUMBER WHILE VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER VAR NUMBER IF VAR VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER VAR NUMBER IF VAR VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL STRING FUNC_CALL VAR VAR VAR |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.