might be cooked
This commit is contained in:
parent
c1f241ff5a
commit
4d4fcd7c00
51
NAJPF/NAJPF.cpp
Normal file
51
NAJPF/NAJPF.cpp
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
#include <cstdio>
|
||||||
|
#include <iostream>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
int test_cases;
|
||||||
|
|
||||||
|
std::scanf("%d", &test_cases);
|
||||||
|
|
||||||
|
char * test_case2 = (char *) malloc(10000000 * sizeof(char));
|
||||||
|
char * token2 = (char *) malloc(10000000 * sizeof(char));
|
||||||
|
|
||||||
|
while (test_cases != 0) {
|
||||||
|
|
||||||
|
size_t pos = 0;
|
||||||
|
int i = 1;
|
||||||
|
int count = 0;
|
||||||
|
std::vector<size_t> positions;
|
||||||
|
|
||||||
|
std::fscanf(stdin, "%s %s", test_case2, token2);
|
||||||
|
|
||||||
|
std::string test_case = test_case2;
|
||||||
|
std::string token = token2;
|
||||||
|
|
||||||
|
while ((pos = test_case.find(token)) != std::string::npos) {
|
||||||
|
|
||||||
|
positions.push_back(pos + i);
|
||||||
|
|
||||||
|
i += pos + 1;
|
||||||
|
test_case.erase(0, pos + 1);
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (positions.size() == 0) {
|
||||||
|
std::printf("Not Found");
|
||||||
|
} else {
|
||||||
|
std::printf("%d\n", count);
|
||||||
|
for (size_t pos : positions) {
|
||||||
|
std::printf("%d ", pos);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
std::printf("\n\n");
|
||||||
|
|
||||||
|
test_cases--;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
21
NAJPF/NAJPF.py
Normal file
21
NAJPF/NAJPF.py
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
def main():
|
||||||
|
test_cases = int(input())
|
||||||
|
while (test_cases != 0):
|
||||||
|
test_case, token = input().split()
|
||||||
|
|
||||||
|
if token in test_case:
|
||||||
|
|
||||||
|
i = 1
|
||||||
|
while token in test_case:
|
||||||
|
print(f'{test_case.find(token) + i} ',end='')
|
||||||
|
test_case = test_case.replace(token, '', 1)
|
||||||
|
i += len(token)
|
||||||
|
|
||||||
|
else:
|
||||||
|
print("Not Found", end='')
|
||||||
|
|
||||||
|
print('\n')
|
||||||
|
test_cases -= 1
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
main()
|
||||||
BIN
NAJPF/main
Executable file
BIN
NAJPF/main
Executable file
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user