Code Submission Evaluation System Login

CSES - HIIT Open 2018

HIIT Open 2018

Contest start:2018-05-26 11:00:00
Contest end:2018-05-26 16:00:00

Task list | Submit code | Submissions | Messages | Scoreboard | Statistics


History
2018-05-26 11:40:57
Task:Inversions
Sender:DROP TABLE
Submission time:2018-05-26 11:40:57
Status:READY
Result:ACCEPTED

Show test data

Code

bits = list(input().rstrip())
n = len(bits)
flip = False
valDict = {True: '1', False: '0'}
# true - 1
# false - 0
flip1 = 0
flip2 = 0
for i in range(n):
	#print(i)
	if bits[i] == valDict[flip]:
		flip1 += 1
		#print("incr flip1")
	else:
		#print("incr flip2")
		flip2 += 1
	flip = not flip
print(min(flip1, flip2))