Code Submission Evaluation System Login

HIIT Open 2018

Start:2018-05-26 11:00:00
End:2018-05-26 16:00:00
 

Tasks | Messages | Scoreboard | Statistics


CSES - HIIT Open 2018 - Results
History
2018-05-26 11:40:57
Task:Inversions
Sender:DROP TABLE
Submission time:2018-05-26 11:40:57
Language:Python3
Status:READY
Result:ACCEPTED

Test results

testverdicttime (s)
#1ACCEPTED0.38 / 1.00details
#2ACCEPTED0.42 / 1.00details
#3ACCEPTED0.45 / 1.00details
#4ACCEPTED0.47 / 1.00details
#5ACCEPTED0.41 / 1.00details

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))

Test details

Test 1

Verdict: ACCEPTED

input
000000000000000000000000000000...
view   save

correct output
500000
view   save

user output
500000
view   save

Test 2

Verdict: ACCEPTED

input
111111111111111111111111111111...
view   save

correct output
500000
view   save

user output
500000
view   save

Test 3

Verdict: ACCEPTED

input
010101010101010101010101010101...
view   save

correct output
0
view   save

user output
0
view   save

Test 4

Verdict: ACCEPTED

input
101010101010101010101010101010...
view   save

correct output
0
view   save

user output
0
view   save

Test 5

Verdict: ACCEPTED

input
110101011010110100100111110110...
view   save

correct output
499476
view   save

user output
499476
view   save