Tsukihjy's picture
download
raw
3.37 kB
import random
def construct_inputs():
inputs_list = []
# Case 1: All same characters with many queries
def case_same_chars():
s = "a" * 1000
ops = ["Q 1 500", "Q 100 900", "Q 1 1000", "Q 500 501"]
return f"{s}\n{len(ops)}\n" + "\n".join(ops)
# Case 2: Alternating pattern with modifications
def case_alternating():
s = "ab" * 500
ops = []
ops.extend([f"Q {i} {i+100}" for i in range(1, 901, 100)])
ops.extend([f"R {i} c" for i in range(1, 1001, 200)])
ops.extend([f"Q {i} {i+50}" for i in range(1, 951, 100)])
return f"{s}\n{len(ops)}\n" + "\n".join(ops)
# Case 3: Heavy insertions at beginning
def case_heavy_insertions():
s = "xyz" * 100
ops = []
for i in range(50):
ops.append(f"I 0 a")
if i % 5 == 0:
ops.append(f"Q 1 {min(i+10, 350)}")
return f"{s}\n{len(ops)}\n" + "\n".join(ops)
# Case 4: Maximum operations with mixed types
def case_max_operations():
s = "abcdefghij" * 1000
ops = []
pos = 1
for i in range(10000):
if i % 3 == 0:
x, y = random.randint(1, min(pos, 10000)), random.randint(1, min(pos, 10000))
ops.append(f"Q {x} {y}")
elif i % 3 == 1:
x = random.randint(1, min(pos, 10000))
c = chr(ord('a') + random.randint(0, 25))
ops.append(f"R {x} {c}")
else:
x = random.randint(0, min(pos, 10000))
c = chr(ord('a') + random.randint(0, 25))
ops.append(f"I {x} {c}")
pos += 1
return f"{s}\n{len(ops)}\n" + "\n".join(ops)
# Case 5: Palindromic string with edge queries
def case_palindrome():
s = "abcdefedcba" * 500
ops = []
length = len(s)
ops.extend([f"Q 1 {length//2}", f"Q {length//2} {length}"])
for i in range(1, length, length//20):
ops.append(f"Q {i} {length-i+1}")
return f"{s}\n{len(ops)}\n" + "\n".join(ops)
# Case 6: Single character string with many operations
def case_single_char():
s = "x"
ops = []
for i in range(1000):
ops.append(f"I {i} y")
if i % 10 == 0:
ops.append(f"Q 1 {i+1}")
return f"{s}\n{len(ops)}\n" + "\n".join(ops)
# Case 7: Worst case LCQ queries
def case_worst_lcq():
s = "a" * 5000 + "b" * 5000
ops = []
for i in range(1, 5001, 500):
for j in range(5001, 10001, 500):
ops.append(f"Q {i} {j}")
return f"{s}\n{len(ops)}\n" + "\n".join(ops)
# Case 8: Frequent modifications at same position
def case_frequent_mods():
s = "test" * 2500
ops = []
for i in range(1000):
ops.append(f"R 5000 {chr(ord('a') + i % 26)}")
if i % 10 == 0:
ops.append(f"Q 4999 5001")
return f"{s}\n{len(ops)}\n" + "\n".join(ops)
inputs_list.extend([
case_same_chars(),
case_alternating(),
case_heavy_insertions(),
case_max_operations(),
case_palindrome(),
case_single_char(),
case_worst_lcq(),
case_frequent_mods()
])
return inputs_list

Xet Storage Details

Size:
3.37 kB
·
Xet hash:
ba26a20c2e3d13caf80f5dad9e61417a2c5e4d8d61552cced1935e98bea539a5

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