Time Limit: 8 sec / Memory Limit: 64 MB Example Input 5 3 2 aaaaa aaa aab Output 1 6
- User
Time Limit: 8 sec / Memory Limit: 64 MB
Example Input
5 3 2 aaaaa aaa aab
Output
1 6
Assistant
n, m, d = map(int, input().split()) a = input().strip() b = input().strip() c = input().strip() # Find all positions where B and C match in A list_b = [] for i in range(n - m + 1): if a[i:i+m] == b: list_b.append(i) list_c = [] for j in range(n - m + 1): if a[j:j+m] == c: list_c.append(j) total = 0 count_i = 0 for i in list_b: cnt = 0 for j in list_c: if abs(i - j) >= d: cnt += 1 if cnt > 0: count_i += 1 total += cnt print(count_i, total)
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.