| 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, 11)]) | |
| operations.extend([f'R {i*50} {"c" if i%2==0 else "d"}' for i in range(1, 11)]) | |
| operations.extend([f'Q {i} {i+400}' for i in range(1, 11)]) | |
| return f"{s}\n{len(operations)}\n" + "\n".join(operations) | |
| # Case 3: Heavy insertion operations | |
| def generate_insertion_heavy(): | |
| s = 'abc' | |
| operations = [] | |
| current_len = 3 | |
| for i in range(50): | |
| operations.append(f'I {current_len} {"xyz"[i%3]}') | |
| current_len += 1 | |
| if i % 5 == 0: | |
| operations.append(f'Q 1 {current_len//2}') | |
| 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', 'Q 4 8', 'Q 5 7', | |
| 'R 6 x', 'Q 1 11', 'Q 2 10', | |
| 'I 0 z', 'Q 1 12', 'Q 2 7' | |
| ] | |
| return f"{s}\n{len(operations)}\n" + "\n".join(operations) | |
| # Case 5: Maximum operations with random pattern | |
| def generate_max_operations(): | |
| s = ''.join(random.choice('abcdefghij') for _ in range(100)) | |
| operations = [] | |
| current_len = 100 | |
| for i in range(1000): | |
| op_type = random.choice(['Q', 'R', 'I']) | |
| if op_type == 'Q': | |
| x = random.randint(1, current_len) | |
| y = random.randint(1, current_len) | |
| operations.append(f'Q {x} {y}') | |
| elif op_type == 'R': | |
| x = random.randint(1, current_len) | |
| c = random.choice('abcdefghij') | |
| operations.append(f'R {x} {c}') | |
| else: # Insert | |
| x = random.randint(0, current_len) | |
| c = random.choice('abcdefghij') | |
| operations.append(f'I {x} {c}') | |
| current_len += 1 | |
| if current_len > 10000: # Prevent string from getting too long | |
| break | |
| return f"{s}\n{len(operations)}\n" + "\n".join(operations) | |
| # Case 6: Repeated substring pattern | |
| def generate_repeated_pattern(): | |
| s = 'abcd' * 250 | |
| operations = [] | |
| for i in range(1, 21): | |
| operations.append(f'Q {i} {i+250}') | |
| operations.append(f'Q {i} {i+500}') | |
| operations.append(f'Q {i} {i+750}') | |
| operations.extend([f'R {i*50} e' for i in range(1, 11)]) | |
| operations.extend([f'Q {i} {i+200}' for i in range(1, 21)]) | |
| return f"{s}\n{len(operations)}\n" + "\n".join(operations) | |
| # Case 7: Single character with many insertions | |
| def generate_single_char_insertions(): | |
| s = 'a' | |
| operations = [] | |
| current_len = 1 | |
| for i in range(100): | |
| operations.append(f'I {current_len} b') | |
| current_len += 1 | |
| operations.append(f'Q 1 {current_len}') | |
| if i % 10 == 0: | |
| operations.append(f'R {i+1} c') | |
| return f"{s}\n{len(operations)}\n" + "\n".join(operations) | |
| # Case 8: Edge case with boundary queries | |
| def generate_boundary_queries(): | |
| s = 'abcdefghijklmnop' | |
| operations = [ | |
| 'Q 1 1', 'Q 16 16', # Same position queries | |
| 'Q 1 2', 'Q 15 16', # Adjacent queries | |
| 'Q 1 16', 'Q 8 9', # Full span and middle | |
| 'R 1 z', 'R 16 z', # Modify boundaries | |
| 'Q 1 16', | |
| 'I 0 x', 'I 17 y', # Insert at boundaries | |
| 'Q 1 18', 'Q 2 17' | |
| ] | |
| 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_repeated_pattern()) | |
| inputs_list.append(generate_single_char_insertions()) | |
| inputs_list.append(generate_boundary_queries()) | |
| return inputs_list | |
| construct_inputs() |
Xet Storage Details
- Size:
- 4.6 kB
- Xet hash:
- 8f007ad9530eb5e651471a5e66e247a5ec134003c02cc9510a6243bd93c03969
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.