diff --git a/NAJPF/NAJPF.cpp b/NAJPF/NAJPF.cpp new file mode 100644 index 0000000..bcfaede --- /dev/null +++ b/NAJPF/NAJPF.cpp @@ -0,0 +1,51 @@ +#include +#include +#include + +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 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; +} + diff --git a/NAJPF/NAJPF.py b/NAJPF/NAJPF.py new file mode 100644 index 0000000..7c25750 --- /dev/null +++ b/NAJPF/NAJPF.py @@ -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() diff --git a/NAJPF/main b/NAJPF/main new file mode 100755 index 0000000..05d9d22 Binary files /dev/null and b/NAJPF/main differ