| 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} 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 = 'xyz' * 100 | |
| operations = [] | |
| for i in range(50): | |
| operations.append(f'I 0 a') | |
| if i % 10 == 0: | |
| operations.append(f'Q 1 {min(50, len(s) + i)}') | |
| operations.extend([f'Q {i} {i+10}' for i in range(1, 21)]) | |
| return f"{s}\n{len(operations)}\n" + "\n".join(operations) | |
| # Case 4: Maximum length with complex operations | |
| def generate_max_length(): | |
| s = ''.join(chr(ord('a') + (i % 26)) for i in range(10000)) | |
| operations = [] | |
| # Many queries on overlapping ranges | |
| for i in range(1, 101, 10): | |
| for j in range(i+1000, min(i+2000, len(s)), 100): | |
| operations.append(f'Q {i} {j}') | |
| # Modifications in middle | |
| for i in range(5000, 5100): | |
| operations.append(f'R {i} z') | |
| # More queries after modifications | |
| for i in range(1, 51, 5): | |
| operations.append(f'Q {i} {i+5000}') | |
| return f"{s}\n{len(operations)}\n" + "\n".join(operations) | |
| # Case 5: Palindromic structure | |
| def generate_palindrome(): | |
| base = 'abcdefghij' | |
| s = base + base[::-1] | |
| s = s * 50 | |
| operations = [] | |
| # Queries on palindromic positions | |
| for i in range(1, 21): | |
| operations.append(f'Q {i} {len(s)-i+1}') | |
| # Break palindrome | |
| operations.append('R 500 x') | |
| # Query again | |
| for i in range(1, 11): | |
| operations.append(f'Q {i} {len(s)-i+1}') | |
| return f"{s}\n{len(operations)}\n" + "\n".join(operations) | |
| # Case 6: Repeated substring pattern | |
| def generate_repeated_pattern(): | |
| pattern = 'abcabc' | |
| s = pattern * 1000 | |
| operations = [] | |
| # Queries on pattern boundaries | |
| for i in range(1, 101, 6): | |
| operations.append(f'Q {i} {i+3000}') | |
| # Insert to break pattern | |
| operations.append('I 1000 x') | |
| # Query after insertion | |
| for i in range(1, 21): | |
| operations.append(f'Q {i} {i+1000}') | |
| return f"{s}\n{len(operations)}\n" + "\n".join(operations) | |
| # Case 7: Single character with many operations | |
| def generate_single_char(): | |
| s = 'a' | |
| operations = [] | |
| # Extend string through insertions | |
| for i in range(100): | |
| operations.append(f'I {i} b') | |
| if i % 20 == 0: | |
| operations.append(f'Q 1 {i+2}') | |
| # Final queries | |
| operations.extend(['Q 1 50', 'Q 25 75', 'Q 1 101']) | |
| return f"{s}\n{len(operations)}\n" + "\n".join(operations) | |
| # Case 8: Edge case with modifications at ends | |
| def generate_edge_modifications(): | |
| s = 'x' + 'a' * 1000 + 'y' | |
| operations = [] | |
| operations.append('Q 1 1002') | |
| operations.append('R 1 a') | |
| operations.append('R 1002 a') | |
| operations.append('Q 1 1002') | |
| operations.extend([f'Q {i} {1003-i}' for i in range(1, 11)]) | |
| 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_max_length()) | |
| inputs_list.append(generate_palindrome()) | |
| inputs_list.append(generate_repeated_pattern()) | |
| inputs_list.append(generate_single_char()) | |
| inputs_list.append(generate_edge_modifications()) | |
| return inputs_list | |
Xet Storage Details
- Size:
- 4.27 kB
- Xet hash:
- 88f983fc1ac5ec1233d4be124f0068862e51cf586b05aa41a349ca339dfd8e2c
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.