Submission #59857638


Source Code Expand

Copy
n, k = map(int,input().split())
s = str(input())
ans_list = []
b_tmp = ""
tmp = ""
for i in range(n):
tmp = s[i]
if tmp in b_tmp:
b_tmp += tmp
else:
ans_list.append(b_tmp)
b_tmp = tmp
ans_list.append(b_tmp)
count = 0
b_1 = 0
for i in range(len(ans_list)):
if "1" in ans_list[i]:
count += 1
if count == k -1:
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
n, k = map(int,input().split())
s = str(input())
ans_list = []
b_tmp = ""
tmp = ""
for i in range(n):
    tmp = s[i]
    if tmp in b_tmp:
        b_tmp += tmp
    else:
        ans_list.append(b_tmp)
        b_tmp = tmp
ans_list.append(b_tmp)

count = 0
b_1 = 0

for i in range(len(ans_list)):
    if "1" in ans_list[i]:
        count += 1
        if count == k -1:
            b_1 = i
        if count == k:
            ans_list.insert(b_1,ans_list[i])
            del ans_list[i +1]
result = "".join(ans_list)
print(result)

Submission Info

Submission Time
Task C - Move Segment
User joshua123
Language Python (CPython 3.11.4)
Score 0
Code Size 551 Byte
Status TLE
Exec Time 2208 ms
Memory 14100 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 300
Status
AC × 2
AC × 26
TLE × 2
Set Name Test Cases
Sample sample_01.txt, sample_02.txt
All min.txt, random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt, random_15.txt, random_16.txt, random_17.txt, random_18.txt, random_19.txt, random_20.txt, random_21.txt, random_22.txt, random_23.txt, random_24.txt, random_25.txt, sample_01.txt, sample_02.txt
Case Name Status Exec Time Memory
min.txt AC 9 ms 8484 KB
random_01.txt AC 135 ms 14100 KB
random_02.txt AC 129 ms 13976 KB
random_03.txt TLE 2208 ms 10648 KB
random_04.txt TLE 2208 ms 10696 KB
random_05.txt AC 1436 ms 11064 KB
random_06.txt AC 90 ms 13376 KB
random_07.txt AC 15 ms 9036 KB
random_08.txt AC 102 ms 10888 KB
random_09.txt AC 42 ms 9472 KB
random_10.txt AC 97 ms 13464 KB
random_11.txt AC 79 ms 11004 KB
random_12.txt AC 94 ms 10832 KB
random_13.txt AC 16 ms 8968 KB
random_14.txt AC 93 ms 13472 KB
random_15.txt AC 19 ms 9008 KB
random_16.txt AC 99 ms 10888 KB
random_17.txt AC 136 ms 10824 KB
random_18.txt AC 95 ms 13424 KB
random_19.txt AC 73 ms 10652 KB
random_20.txt AC 99 ms 10828 KB
random_21.txt AC 49 ms 9396 KB
random_22.txt AC 93 ms 13400 KB
random_23.txt AC 32 ms 9440 KB
random_24.txt AC 95 ms 10840 KB
random_25.txt AC 119 ms 10132 KB
sample_01.txt AC 9 ms 8508 KB
sample_02.txt AC 9 ms 8508 KB


2025-04-05 (Sat)
23:45:46 +00:00