CSES - HIIT Open 2018 - Results
Submission details
Task:Inversions
Sender:El Numero Uno
Submission time:2018-05-26 11:27:05 +0300
Language:Python3
Status:READY
Result:ACCEPTED
Test results
testverdicttime
#1ACCEPTED0.40 sdetails
#2ACCEPTED0.45 sdetails
#3ACCEPTED0.38 sdetails
#4ACCEPTED0.39 sdetails
#5ACCEPTED0.47 sdetails

Code

s = input()

b1, b2 = "0", "1"
i1, i2 = 0, 0
for c in s:
	if (c == b1):
		i1 += 1
	if (c == b2):
		i2 += 1
	b1 = "1" if b1 == "0" else "0"
	b2 = "1" if b2 == "0" else "0"
if (i1 < i2):
	print(i1)
else:
	print(i2)

Test details

Test 1

Verdict: ACCEPTED

input
000000000000000000000000000000...

correct output
500000

user output
500000

Test 2

Verdict: ACCEPTED

input
111111111111111111111111111111...

correct output
500000

user output
500000

Test 3

Verdict: ACCEPTED

input
010101010101010101010101010101...

correct output
0

user output
0

Test 4

Verdict: ACCEPTED

input
101010101010101010101010101010...

correct output
0

user output
0

Test 5

Verdict: ACCEPTED

input
110101011010110100100111110110...

correct output
499476

user output
499476