| 模型 | 模型答案 | 正确答案 |
|---|---|---|
| 金声玉亮2.0 | ```python import sys def count_repetitive_substrings(S): count = 0 current_length = 1 for i in range(1, len(S)): if S[i] == S[i - 1]: current_length += 1 else: count += (current_length * (current_length + 1)) // 2 current_length = 1 count += (current_length * (current_length + 1)) // 2 return count # Read input from stdin N = int(sys.stdin.readline().strip()) S = sys.stdin.readline().strip() # Output the result print(count_repetitive_substrings(S)) ``` |
[{"input": "6\naaabaa\n", "output": "4\n", "testtype": "stdin"}, {"input": "1\nx\n", "output": "1\n", "testtype": "stdin"}, {"input": "12\nssskkyskkkky\n", "output": "8\n", "testtype": "stdin"}] |
| deepseek-r1 | ```python n = int(input()) s = input().strip() from collections import defaultdict max_counts = defaultdict(int) if n == 0: print(0) exit() current_char = s[0] current_length = 1 for i in range(1, n): if s[i] == current_char: current_length += 1 else: if current_length > max_counts[current_char]: max_counts[current_char] = current_length current_char = s[i] current_length = 1 # Process the last run if current_length > max_counts[current_char]: max_counts[current_char] = current_length print(sum(max_counts.values())) ``` |
[{"input": "6\naaabaa\n", "output": "4\n", "testtype": "stdin"}, {"input": "1\nx\n", "output": "1\n", "testtype": "stdin"}, {"input": "12\nssskkyskkkky\n", "output": "8\n", "testtype": "stdin"}] |
| gpto1 | ```python # YOUR CODE HERE import sys import threading def main(): N = int(sys.stdin.readline()) S = sys.stdin.readline().strip() max_run_length = dict((chr(ord('a') + i), 0) for i in range(26)) current_run_char = S[0] current_run_length =1 for i in range(1, N): ch = S[i] if ch == current_run_char: current_run_length +=1 else: c = current_run_char max_run_length[c] = max(max_run_length[c], current_run_length) current_run_char = ch current_run_length =1 # Update for the last run c = current_run_char max_run_length[c] = max(max_run_length[c], current_run_length) substrings = set() for c in max_run_length: L = max_run_length[c] for length in range(1, L+1): substrings.add(c * length) print(len(substrings)) threading.Thread(target=main).start() ``` |
[{"input": "6\naaabaa\n", "output": "4\n", "testtype": "stdin"}, {"input": "1\nx\n", "output": "1\n", "testtype": "stdin"}, {"input": "12\nssskkyskkkky\n", "output": "8\n", "testtype": "stdin"}] |
| gpt-4o-2024-08-06 | ```python # YOUR CODE HERE def count_repeated_char_substrings(N, S): count = 0 i = 0 while i < N: # Start of a new sequence of the same character j = i while j < N and S[j] == S[i]: j += 1 # Length of the sequence of the same character length = j - i # Add the number of substrings that can be formed from this sequence count += (length * (length + 1)) // 2 # Move to the next different character i = j return count import sys input = sys.stdin.read data = input().split() N = int(data[0]) S = data[1] result = count_repeated_char_substrings(N, S) print(result) ``` |
[{"input": "6\naaabaa\n", "output": "4\n", "testtype": "stdin"}, {"input": "1\nx\n", "output": "1\n", "testtype": "stdin"}, {"input": "12\nssskkyskkkky\n", "output": "8\n", "testtype": "stdin"}] |
| Qwen2-72B-Instruct | ```python n = int(input()) s = input() ans = 0 i = 0 while i < n: j = i + 1 while j < n and s[i] == s[j]: j += 1 ans += (j - i) * (j - i + 1) // 2 i = j print(ans) ``` ``` |
[{"input": "6\naaabaa\n", "output": "4\n", "testtype": "stdin"}, {"input": "1\nx\n", "output": "1\n", "testtype": "stdin"}, {"input": "12\nssskkyskkkky\n", "output": "8\n", "testtype": "stdin"}] |
| DeepSeek-Coder-V2-Lite-Instruct | ```python # YOUR CODE HERE def count_repetitive_substrings(N, S): count = 0 for i in range(N): if i < N - 1 and S[i] == S[i + 1]: count += 1 j = i + 2 while j < N and S[j] == S[i]: count += 1 j += 1 return count # Read input from stdin import sys input = sys.stdin.read data = input().split() N = int(data[0]) S = data[1] # Solve the problem and write the answer to stdout answer = count_repetitive_substrings(N, S) print(answer) ``` |
[{"input": "6\naaabaa\n", "output": "4\n", "testtype": "stdin"}, {"input": "1\nx\n", "output": "1\n", "testtype": "stdin"}, {"input": "12\nssskkyskkkky\n", "output": "8\n", "testtype": "stdin"}] |
| Meta-Llama-3.1-405B-Instruct-Turbo | ```python import sys def solve(): n = int(input()) s = input() ans = 0 i = 0 while i < n: j = i + 1 while j < n and s[i] == s[j]: j += 1 ans += (j - i) i = j print(ans) if __name__ == "__main__": solve() ``` |
[{"input": "6\naaabaa\n", "output": "4\n", "testtype": "stdin"}, {"input": "1\nx\n", "output": "1\n", "testtype": "stdin"}, {"input": "12\nssskkyskkkky\n", "output": "8\n", "testtype": "stdin"}] |
| Meta-Llama-3.1-70B-Instruct-Turbo | ```python import sys def solve(): n = int(input()) s = input() ans = set() for i in range(n): for j in range(i + 1, n + 1): if len(set(s[i:j])) == 1: ans.add(s[i:j]) print(len(ans)) if __name__ == "__main__": solve() ``` |
[{"input": "6\naaabaa\n", "output": "4\n", "testtype": "stdin"}, {"input": "1\nx\n", "output": "1\n", "testtype": "stdin"}, {"input": "12\nssskkyskkkky\n", "output": "8\n", "testtype": "stdin"}] |
| baichuan4 | ```python # YOUR CODE HERE import sys # Read input from stdin input_data = sys.stdin.read().splitlines() n = int(input_data[0]) s = input_data[1] # Function to count repetitions of one character def count_repetitive_substrings(s): count = 0 current_char = s[0] current_length = 1 for i in range(1, len(s)): if s[i] == current_char: current_length += 1 else: count += (current_length * (current_length + 1)) // 2 current_char = s[i] current_length = 1 # Count for the last sequence of the same character count += (current_length * (current_length + 1)) // 2 return count # Calculate and print the result result = count_repetitive_substrings(s) print(result) ``` |
[{"input": "6\naaabaa\n", "output": "4\n", "testtype": "stdin"}, {"input": "1\nx\n", "output": "1\n", "testtype": "stdin"}, {"input": "12\nssskkyskkkky\n", "output": "8\n", "testtype": "stdin"}] |
| doubao | ```python N = int(input()) S = input() count = 0 for i in range(N): for j in range(i + 1, N + 1): sub = S[i:j] if len(set(sub)) == 1: count += 1 print(count) ``` |
[{"input": "6\naaabaa\n", "output": "4\n", "testtype": "stdin"}, {"input": "1\nx\n", "output": "1\n", "testtype": "stdin"}, {"input": "12\nssskkyskkkky\n", "output": "8\n", "testtype": "stdin"}] |
| gpto1 | ```python # YOUR CODE HERE import sys import threading def main(): N = int(sys.stdin.readline()) S = sys.stdin.readline().strip() max_run_length = dict((chr(ord('a') + i), 0) for i in range(26)) current_run_char = S[0] current_run_length =1 for i in range(1, N): ch = S[i] if ch == current_run_char: current_run_length +=1 else: c = current_run_char max_run_length[c] = max(max_run_length[c], current_run_length) current_run_char = ch current_run_length =1 # Update for the last run c = current_run_char max_run_length[c] = max(max_run_length[c], current_run_length) substrings = set() for c in max_run_length: L = max_run_length[c] for length in range(1, L+1): substrings.add(c * length) print(len(substrings)) threading.Thread(target=main).start() ``` |
[{"input": "6\naaabaa\n", "output": "4\n", "testtype": "stdin"}, {"input": "1\nx\n", "output": "1\n", "testtype": "stdin"}, {"input": "12\nssskkyskkkky\n", "output": "8\n", "testtype": "stdin"}] |
| kimi | ```python N = int(input()) S = input() ans = 0 cnt = 1 for i in range(1, N): if S[i] == S[i - 1]: cnt += 1 else: ans += cnt * (cnt + 1) // 2 cnt = 1 ans += cnt * (cnt + 1) // 2 print(ans) ``` |
[{"input": "6\naaabaa\n", "output": "4\n", "testtype": "stdin"}, {"input": "1\nx\n", "output": "1\n", "testtype": "stdin"}, {"input": "12\nssskkyskkkky\n", "output": "8\n", "testtype": "stdin"}] |
| minimax | ```python # YOUR CODE HERE N = int(input()) S = input() def count_repetitions(S): count = 0 for i in range(len(S)): for j in range(i, len(S)): if S[i] == S[j]: # Check if the substring from i to j is a repetition of one character if j - i + 1 == S.count(S[i], i, j + 1): count += 1 return count print(count_repetitions(S)) ``` |
[{"input": "6\naaabaa\n", "output": "4\n", "testtype": "stdin"}, {"input": "1\nx\n", "output": "1\n", "testtype": "stdin"}, {"input": "12\nssskkyskkkky\n", "output": "8\n", "testtype": "stdin"}] |
| wenxinyiyan | ```python # Read the input N = int(input()) S = input() # Initialize the count of repeating substrings count = 0 # Iterate through each character in the string for i in range(N): # Check if the current character is the same as the next character # If it is, increment the count and continue checking until the characters are different while i < N - 1 and S[i] == S[i + 1]: count += 1 i += 1 # Add 1 to the count to account for the single occurrence of the current character count += 1 # However, the above approach would count each substring multiple times if it appears more than once in the string. # To fix this, we use a set to keep track of the unique substrings we have encountered. # Alternative approach using a set to count unique repeating substrings unique_substrings = set() current_substring = '' for char in S: if current_substring == '' or char == current_substring[-1]: current_substring += char else: if len(current_substring) > 1: # Only add substrings of length > 1 to the set unique_substrings.add(current_substring) current_substring = char # Check if the last substring was a repeating one and add it if necessary if len(current_substring) > 1: unique_substrings.add(current_substring) # The final count is the number of unique repeating substrings plus the number of single characters final_count = len(unique_substrings) + N # N accounts for single characters # However, we need to subtract the number of single characters that were already counted as part of a repeating substring # This can be done by subtracting the number of unique repeating substrings of length > 1 final_count -= len([s for s in unique_substrings if len(s) > 1]) # Print the final count print(final_count) # Note: The alternative approach is more complex and may not be necessary for this problem. # The first approach can be modified to directly get the correct answer without using a set. # Here's a simplified version of the first approach that gives the correct answer: # Simplified approach count = 0 consecutive_count = 0 for i in range(N): if i > 0 and S[i] == S[i - 1]: consecutive_count += 1 else: consecutive_count = 1 count += consecutive_count print(count) ``` **Note**: The simplified approach at the end is the preferred solution for this problem. It directly calculates the count of non-empty substrings that are repetitions of one character without the need for a set to store unique substrings. The alternative approach, while correct, introduces additional complexity that is not necessary to solve the problem. |
[{"input": "6\naaabaa\n", "output": "4\n", "testtype": "stdin"}, {"input": "1\nx\n", "output": "1\n", "testtype": "stdin"}, {"input": "12\nssskkyskkkky\n", "output": "8\n", "testtype": "stdin"}] |
| zhipu | ```python def main(): import sys input = sys.stdin.read data = input().split() N = int(data[0]) S = data[1] count = 0 i = 0 while i < N: start = i while i < N and S[i] == S[start]: i += 1 length = i - start count += length * (length + 1) // 2 print(count) if __name__ == "__main__": main() ``` |
[{"input": "6\naaabaa\n", "output": "4\n", "testtype": "stdin"}, {"input": "1\nx\n", "output": "1\n", "testtype": "stdin"}, {"input": "12\nssskkyskkkky\n", "output": "8\n", "testtype": "stdin"}] |
| deepseek-v3 | Error code: 400 - {'error': {'code': 'RequestTimeOut', 'param': None, 'message': 'Request timed out, please try again later.', 'type': 'RequestTimeOut'}, 'id': 'chatcmpl-711ff086-5aa6-9912-b575-3ffa942de27f', 'request_id': '711ff086-5aa6-9912-b575-3ffa942de27f'} | [{"input": "6\naaabaa\n", "output": "4\n", "testtype": "stdin"}, {"input": "1\nx\n", "output": "1\n", "testtype": "stdin"}, {"input": "12\nssskkyskkkky\n", "output": "8\n", "testtype": "stdin"}] |