I was trying to solve the above problem, but on submitting I am getting Time Limit Exceed error. I have tried test cases, and its giving me the desired output. But, on submitting facing this Time Limit issue.
Can someone please help me out.
This is the code which I wrote -:
try:
T = int(input())
for k in range(0,T):
N = int(input())
alpha = []
for j in range(0,N):
word,boolean = input().split()
boolean = int(boolean)
if len(alpha) == 0:
alpha.append([word,boolean])
else:
for i in alpha:
if i[0] == word and i[1] == boolean:
alpha.append([word,boolean])
break
elif i[0] == word and i[1] !=boolean:
continue
else:
alpha.append([word,boolean])
break
print(len(alpha))
except:
pass
This is the link for my solution
https://www.codechef.com/viewsolution/35226030
Thanks in advance.