| import random | |
| def construct_inputs(): | |
| inputs_list = [] | |
| # Case 1: All same characters with many queries | |
| def generate_same_char_case(): | |
| s = 'a' * 1000 | |
| operations = ['Q 1 500', 'Q 250 750', '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_case(): | |
| s = 'ab' * 500 | |
| operations = [] | |
| operations.extend([f'Q {i} {i+500}' for i in range(1, 11)]) | |
| operations.extend([f'R {i} c' for i in range(100, 111)]) | |
| 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: Many insertions at beginning | |
| def generate_insertion_heavy_case(): | |
| s = 'test' | |
| operations = [] | |
| for i in range(50): | |
| operations.append(f'I 0 x') | |
| if i % 10 == 0: | |
| operations.append(f'Q 1 {min(i+5, 50)}') | |
| return f"{s}\n{len(operations)}\n" + "\n".join(operations) | |
| # Case 4: Palindromic string with edge queries | |
| def generate_palindrome_case(): | |
| s = 'abcdefedcba' | |
| operations = [] | |
| operations.extend([f'Q {i} {12-i}' for i in range(1, 6)]) | |
| operations.append('R 6 x') | |
| operations.extend([f'Q {i} {12-i}' for i in range(1, 6)]) | |
| operations.extend([f'I {i} z' for i in range(0, 5)]) | |
| operations.extend([f'Q 1 {i}' for i in range(10, 16)]) | |
| return f"{s}\n{len(operations)}\n" + "\n".join(operations) | |
| # Case 5: Maximum operations with random pattern | |
| def generate_max_operations_case(): | |
| s = 'abcdefghijklmnopqrstuvwxyz' * 100 | |
| operations = [] | |
| # Add many modifications | |
| for i in range(1000): | |
| pos = random.randint(1, len(s)) | |
| char = chr(ord('a') + random.randint(0, 25)) | |
| operations.append(f'R {pos} {char}') | |
| # Add insertions | |
| for i in range(500): | |
| pos = random.randint(0, min(len(s) + i, 10000)) | |
| char = chr(ord('a') + random.randint(0, 25)) | |
| operations.append(f'I {pos} {char}') | |
| # Add queries | |
| for i in range(1000): | |
| x = random.randint(1, min(3000, 10000)) | |
| y = random.randint(1, min(3000, 10000)) | |
| operations.append(f'Q {x} {y}') | |
| # Shuffle operations | |
| random.shuffle(operations) | |
| operations = operations[:10000] # Limit to max queries | |
| return f"{s}\n{len(operations)}\n" + "\n".join(operations) | |
| # Case 6: Repeated substring pattern | |
| def generate_repeated_pattern_case(): | |
| s = 'abcabc' * 500 | |
| operations = [] | |
| operations.extend([f'Q {i} {i+1500}' for i in range(1, 21)]) | |
| operations.extend([f'R {i*100} x' for i in range(1, 11)]) | |
| operations.extend([f'Q {i} {i+1000}' for i in range(1, 16)]) | |
| return f"{s}\n{len(operations)}\n" + "\n".join(operations) | |
| # Case 7: Single character string with many operations | |
| def generate_single_char_case(): | |
| s = 'x' | |
| operations = [] | |
| for i in range(100): | |
| operations.append(f'I {i} y') | |
| if i % 5 == 0: | |
| operations.append(f'Q 1 {i+2}') | |
| return f"{s}\n{len(operations)}\n" + "\n".join(operations) | |
| # Case 8: Long common prefixes | |
| def generate_long_prefix_case(): | |
| prefix = 'a' * 1000 | |
| s = prefix + 'b' + prefix + 'c' | |
| operations = [] | |
| operations.append('Q 1 1002') | |
| operations.append('R 1001 c') | |
| operations.append('Q 1 1002') | |
| operations.extend([f'I {i*200} x' for i in range(1, 11)]) | |
| operations.extend([f'Q 1 {1200 + i*10}' for i in range(1, 6)]) | |
| return f"{s}\n{len(operations)}\n" + "\n".join(operations) | |
| inputs_list.append(generate_same_char_case()) | |
| inputs_list.append(generate_alternating_case()) | |
| inputs_list.append(generate_insertion_heavy_case()) | |
| inputs_list.append(generate_palindrome_case()) | |
| inputs_list.append(generate_max_operations_case()) | |
| inputs_list.append(generate_repeated_pattern_case()) | |
| inputs_list.append(generate_single_char_case()) | |
| inputs_list.append(generate_long_prefix_case()) | |
| return inputs_list | |
Xet Storage Details
- Size:
- 4.35 kB
- Xet hash:
- a3e7b7c9fc3033ac5f41e687ed951be8de9ea6d62352e8871d93be7eddc8604a
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.