Submission #4953203


Source Code Expand

Copy
S = input()
cnt = 0
s = S[0]
for i in range(1, len(S)):
    si = int(S[i])
    #print(s, si)
    if int(s) == int(si):
        #print("hit")
        s = 1 - si
        cnt += 1
    else:
        s = si

# reverse first
cnt2 = 1
s = 1 - int(S[0])
for i in range(1, len(S)):
    si = int(S[i])
    #print(s, si)
    if int(s) == int(si):
        #print("hit")
        s = 1 - si
        cnt2 += 1
    else:
        s = si

#print(cnt, cnt2)
print(min(cnt, cnt2))

Submission Info

Submission Time
Task C - Coloring Colorfully
User showyou41
Language Python3 (3.4.3)
Score 300
Code Size 487 Byte
Status
Exec Time 149 ms
Memory 3316 KB

Test Cases

Set Name Score / Max Score Test Cases
All 300 / 300 sample_01, sample_02, sample_03, testcase_01, testcase_02, testcase_03, testcase_04, testcase_05, testcase_06, testcase_07, testcase_08, testcase_09, testcase_10, testcase_11, testcase_12, testcase_13, testcase_14, testcase_15, testcase_16, testcase_17
Sample 0 / 0 sample_01, sample_02, sample_03
Case Name Status Exec Time Memory
sample_01 17 ms 3064 KB
sample_02 17 ms 3064 KB
sample_03 17 ms 3064 KB
testcase_01 94 ms 3188 KB
testcase_02 78 ms 3316 KB
testcase_03 149 ms 3188 KB
testcase_04 145 ms 3188 KB
testcase_05 137 ms 3188 KB
testcase_06 137 ms 3188 KB
testcase_07 141 ms 3188 KB
testcase_08 141 ms 3188 KB
testcase_09 17 ms 3064 KB
testcase_10 144 ms 3188 KB
testcase_11 144 ms 3188 KB
testcase_12 144 ms 3188 KB
testcase_13 147 ms 3188 KB
testcase_14 138 ms 3188 KB
testcase_15 142 ms 3188 KB
testcase_16 137 ms 3188 KB
testcase_17 138 ms 3188 KB