Hi,
Brief story: I’m new to this site and am trying the alien problem. I tried doing it once and got the correct answer on my side but got time exceeded upon submitting. I thought it was because of the slow input method I was using so I tried a different way with an apparently better method. Still got time exceeded. I realize it will be difficult to fully follow my code but can someone please tell me if theres something obvious that I’m doing that will make it too slow:
first attempt:##
N = int(raw_input())
times = []
for a in range(N):
input = raw_input()
space = input.find(" ")
S = int(input[:space])
E = int(input[space+1:])
times.append((S,E))
num_groups = int(raw_input())
groups = []
output = []
for b in range(num_groups):
new_input = raw_input()
input_split = new_input.split()
groups.append([])
output.append(set())
for c in range(1,int(input_split[0])+1):
el = int(input_split[c])
groups[b].append(eli)
for f in times:
if el >= f[0] and el <= f[1]:
output[b].add(f)
for a in output:
print len(a)
second attempt:##
import sys
N = int(sys.stdin.readline())
rem_array = sys.stdin.readlines()
times = list()
for a in range(N):
space = rem_array[a].find(' ')
newline = rem_array[a].find('\n')
times.append([int(rem_array[a][:space]),int(rem_array[a][space+1:newline])])
group_list = rem_array[N+1:]
#print group_list
result = [[] for num in range(len(group_list))]
for d in range(len(times)):
for e in range(len(group_list)):
el = map(int,group_list[e].rstrip().split()[1:])
for questlove in el:
if questlove >= times[d][0] and questlove <= times[d][1]:
if d not in result[e]:
result[e].append(d)
for e in result:
print len(e)
thanks in advance!