Tsukihjy's picture
download
raw
3.97 kB
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 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_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' for i in range(1, 6)])
operations.extend([f'Q {i} {i+100}' for i in range(1, 6)])
return f"{s}\n{len(operations)}\n" + "\n".join(operations)
# Case 3: Heavy insertion operations
def generate_insertion_heavy():
s = 'xyz'
operations = []
for i in range(50):
operations.append(f'I {i} a')
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 random operations
def generate_max_length_input():
s = ''.join(random.choice('abcdefghij') for _ in range(10000))
operations = []
for _ in range(100):
op_type = random.choice(['Q', 'R', 'I'])
if op_type == 'Q':
x = random.randint(1, len(s))
y = random.randint(1, len(s))
operations.append(f'Q {x} {y}')
elif op_type == 'R':
x = random.randint(1, len(s))
c = random.choice('abcdefghij')
operations.append(f'R {x} {c}')
else: # Insert
x = random.randint(0, len(s))
c = random.choice('abcdefghij')
operations.append(f'I {x} {c}')
s = s[:x] + c + s[x:]
return f"{s[:10000]}\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.extend(['R 500 x', 'Q 1 500', 'I 999 y', 'Q 500 1000'])
return f"{s}\n{len(operations)}\n" + "\n".join(operations)
# Case 7: Single character with many modifications
def generate_single_char_heavy_mod():
s = 'a'
operations = []
chars = 'abcdefghijklmnopqrstuvwxyz'
for i, c in enumerate(chars[:20]):
operations.append(f'R 1 {c}')
operations.append(f'I {i+1} {c}')
if i % 5 == 0:
operations.append(f'Q 1 {i+2}')
return f"{s}\n{len(operations)}\n" + "\n".join(operations)
# Case 8: Edge case with boundary queries
def generate_boundary_queries():
s = 'boundary'
operations = []
operations.extend(['Q 1 1', 'Q 8 8', 'Q 1 8'])
operations.extend(['I 0 x', 'Q 1 2', 'I 9 y', 'Q 9 10'])
operations.extend(['R 1 z', 'Q 1 9'])
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_input())
inputs_list.append(generate_repeated_pattern())
inputs_list.append(generate_single_char_heavy_mod())
inputs_list.append(generate_boundary_queries())
return inputs_list

Xet Storage Details

Size:
3.97 kB
·
Xet hash:
5b9626b42838086e3bc79700f2e792ca2fbeb576bfaac9e11e98148ea60146bf

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.