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
def get_substrings(s): substr = set() n = len(s) for i in range(n): for j in range(i+1, n+1): substr.add(s[i:j]) return substr # Read input n, m, k = map(int, input().split()) s1 = input().strip() s2 = input().strip() s3 = input().strip() # Generate all substrings sub1 = get_substrings(s1) sub2 = get_substrings(s2) sub3 = get_substrings(s3) # Compute intersections common_all = sub1 & sub2 & sub3 count_all = len(common_all) # Compute pairwise intersections pair12 = sub1 & sub2 pair13 = sub1 & sub3 pair23 = sub2 & sub3 sum_pairs = len(pair12) + len(pair13) + len(pair23) print(count_all, sum_pairs)
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.