| import random | |
| def construct_inputs(): | |
| inputs_list = [] | |
| # Case 1: All same characters with many queries | |
| def generate_same_char_input(): | |
| s = 'a' * 1000 | |
| operations = ['Q 1 500', 'Q 100 900', 'Q 1 1000', 'R 500 b', 'Q 1 500', 'Q 500 1000'] | |
| return f"{s}\n{len(operations)}\n" + "\n".join(operations) | |
| # Case 2: Alternating pattern with modifications | |
| def generate_alternating_input(): | |
| s = 'ab' * 500 | |
| operations = [] | |
| operations.extend([f'Q {i} {i+500}' for i in range(1, 6)]) | |
| operations.extend([f'R {i} c' for i in range(100, 110)]) | |
| operations.extend([f'Q {i} {i+400}' for i in range(1, 6)]) | |
| return f"{s}\n{len(operations)}\n" + "\n".join(operations) | |
| # Case 3: Heavy insertion at beginning | |
| def generate_insertion_heavy(): | |
| s = 'test' | |
| operations = [] | |
| for i in range(50): | |
| operations.append(f'I 0 z') | |
| operations.extend(['Q 1 25', 'Q 10 40', 'Q 1 54']) | |
| return f"{s}\n{len(operations)}\n" + "\n".join(operations) | |
| # Case 4: Palindromic string with edge queries | |
| def generate_palindrome_input(): | |
| s = 'abcdefedcba' | |
| operations = [ | |
| 'Q 1 11', 'Q 2 10', 'Q 3 9', | |
| 'R 6 x', | |
| 'Q 1 11', 'Q 5 7', | |
| 'I 6 y', | |
| 'Q 1 7', 'Q 6 12' | |
| ] | |
| return f"{s}\n{len(operations)}\n" + "\n".join(operations) | |
| # Case 5: Maximum operations with random pattern | |
| def generate_max_operations(): | |
| s = 'abcdefghij' * 100 | |
| operations = [] | |
| # Add many queries | |
| for _ in range(100): | |
| x = random.randint(1, 1000) | |
| y = random.randint(1, 1000) | |
| operations.append(f'Q {x} {y}') | |
| # Add modifications | |
| for _ in range(50): | |
| pos = random.randint(1, 1000) | |
| char = chr(ord('a') + random.randint(0, 25)) | |
| operations.append(f'R {pos} {char}') | |
| # Add more queries after modifications | |
| for _ in range(50): | |
| x = random.randint(1, 1000) | |
| y = random.randint(1, 1000) | |
| operations.append(f'Q {x} {y}') | |
| return f"{s}\n{len(operations)}\n" + "\n".join(operations) | |
| # Case 6: Single character string with maximum insertions | |
| def generate_single_char_max_insert(): | |
| s = 'x' | |
| operations = [] | |
| current_len = 1 | |
| # Insert many characters | |
| for i in range(1000): | |
| pos = random.randint(0, current_len) | |
| char = chr(ord('a') + (i % 26)) | |
| operations.append(f'I {pos} {char}') | |
| current_len += 1 | |
| # Add queries | |
| for _ in range(100): | |
| x = random.randint(1, min(current_len, 1001)) | |
| y = random.randint(1, min(current_len, 1001)) | |
| operations.append(f'Q {x} {y}') | |
| return f"{s}\n{len(operations)}\n" + "\n".join(operations) | |
| # Case 7: Repeated substring pattern | |
| def generate_repeated_pattern(): | |
| s = 'abcabc' * 166 # Close to 1000 chars | |
| operations = [] | |
| # Queries that should find long common prefixes | |
| operations.extend([f'Q 1 {3*i+1}' for i in range(1, 10)]) | |
| # Modify to break patterns | |
| for i in range(100, 200, 10): | |
| operations.append(f'R {i} z') | |
| # More queries after modifications | |
| operations.extend([f'Q {i} {i+300}' for i in range(1, 20, 3)]) | |
| return f"{s}\n{len(operations)}\n" + "\n".join(operations) | |
| # Case 8: Edge case with boundary queries | |
| def generate_boundary_queries(): | |
| s = 'boundary' * 125 | |
| operations = [ | |
| 'Q 1 1', # Same position | |
| 'Q 1 1000', # Maximum distance | |
| 'Q 999 1000', # Adjacent at end | |
| 'R 1 z', | |
| 'Q 1 2', | |
| 'I 1000 x', | |
| 'Q 1000 1001', # Query new last positions | |
| 'Q 1 1001' | |
| ] | |
| return f"{s}\n{len(operations)}\n" + "\n".join(operations) | |
| inputs_list.append(generate_same_char_input()) | |
| inputs_list.append(generate_alternating_input()) | |
| inputs_list.append(generate_insertion_heavy()) | |
| inputs_list.append(generate_palindrome_input()) | |
| inputs_list.append(generate_max_operations()) | |
| inputs_list.append(generate_single_char_max_insert()) | |
| inputs_list.append(generate_repeated_pattern()) | |
| inputs_list.append(generate_boundary_queries()) | |
| return inputs_list | |
Xet Storage Details
- Size:
- 4.53 kB
- Xet hash:
- 46286c1a785b56a0360aaa9dd9530dc2ba1d5c76b4c5a0f565a9a24ba3cfea6e
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.