| 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 pattern | |
| def generate_insertion_heavy(): | |
| s = 'abc' | |
| operations = [] | |
| for i in range(50): | |
| operations.append(f'I {i} x') | |
| if i % 10 == 0: | |
| operations.append(f'Q 1 {i+4}') | |
| return f"{s}\n{len(operations)}\n" + "\n".join(operations) | |
| # Case 4: Palindromic string with edge queries | |
| def generate_palindrome_input(): | |
| s = 'abcdefedcba' | |
| operations = [] | |
| operations.extend(['Q 1 11', 'Q 2 10', 'Q 3 9', 'Q 4 8', 'Q 5 7']) | |
| operations.extend(['R 6 x', 'Q 1 11', 'I 0 z', 'Q 1 12']) | |
| return f"{s}\n{len(operations)}\n" + "\n".join(operations) | |
| # Case 5: Maximum length with mixed operations | |
| def generate_max_length(): | |
| s = ''.join(chr(ord('a') + (i % 26)) for i in range(10000)) | |
| operations = [] | |
| # Add queries at various positions | |
| for i in range(0, 100, 10): | |
| operations.append(f'Q {i+1} {5000+i}') | |
| # Add modifications | |
| for i in range(1000, 1050): | |
| operations.append(f'R {i} z') | |
| # Add more queries after modifications | |
| for i in range(0, 50, 5): | |
| operations.append(f'Q {i+1} {3000+i}') | |
| return f"{s}\n{len(operations)}\n" + "\n".join(operations) | |
| # Case 6: Repeated substring pattern | |
| def generate_repeated_pattern(): | |
| s = 'abcd' * 250 | |
| operations = [] | |
| # Queries that should find long common prefixes | |
| operations.extend([f'Q {i} {i+4}' for i in range(1, 997, 4)]) | |
| # Modify to break patterns | |
| operations.extend([f'R {i} x' for i in range(4, 1000, 100)]) | |
| # Query again | |
| operations.extend([f'Q {i} {i+4}' for i in range(1, 50, 4)]) | |
| return f"{s}\n{len(operations)}\n" + "\n".join(operations) | |
| # Case 7: Single character with many operations | |
| def generate_single_char(): | |
| s = 'a' | |
| operations = [] | |
| for i in range(1000): | |
| operations.append(f'I {i} b') | |
| if i % 100 == 0: | |
| operations.append(f'Q 1 {i+2}') | |
| return f"{s}\n{len(operations)}\n" + "\n".join(operations) | |
| # Case 8: Edge case with position 1 queries | |
| def generate_edge_queries(): | |
| s = 'abcdefghij' | |
| operations = [] | |
| operations.extend([f'Q 1 {i}' for i in range(2, 11)]) | |
| operations.extend([f'Q {i} 1' for i in range(2, 11)]) | |
| operations.append('I 5 x') | |
| operations.extend([f'Q 1 {i}' for i in range(2, 12)]) | |
| 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_length()) | |
| inputs_list.append(generate_repeated_pattern()) | |
| inputs_list.append(generate_single_char()) | |
| inputs_list.append(generate_edge_queries()) | |
| return inputs_list | |
Xet Storage Details
- Size:
- 3.77 kB
- Xet hash:
- c5bcfa9b4a881e9dd97de30b6237393b5ac81174cf2f3bd3f7febd6cb8f4ca95
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.