Yes, there is. Make a list of event times, there are discrete point of times from 0 to 24x60.
In each of those point of time, you can list the ins and outs activities. For instance, if there’s an activity starting at 5 ending at 10, then insert an “in” event at time slot 5, and and “out” event at time slot 10.
You just need start with empty assignment, and go thru each time t, and see if there are ins or outs events there.
Process the outs first, so you can free C or J who’s assigned. Then proceed to see if there are ins events at the same time and start assigning C or J. If both are already assigned, then this is impossible.
That’s it. Your processing time would only amount to the maximum number of events (ins and outs). Should count as O(n).
1 Like
Here is a link to my submissions.
Yeah for sorting one can use counting sort too. That will be O(24 * 60).
I think u cheated this solution from @anon55659401 ‘s solution ? isn’ it ?
how do you know, that he copied the solutions?
nope,but it seems so bad that a 6 star coder have done this!
1 Like
bro, i finished this all problems around 2 PM in afternoon and in other thread , u falsely claimed that i copied the code and submitted around 8 PM , please clarify it once before spitting sh*t from your mouth.
agar copy kiya hota toh 100 aate mere , 75 nahi …
i submitted at 10:34:00 hrs. from the start of round .
I think there is no point saying who cheated or not because in next round automatically everything will be back to usual
2 Likes
my second case of 5th ques. was giving WA
my rank was 297 , later it slipped to 543
for x in range(int(input())):
n1=int(input())
time=[]
for i in range(n1):
temp=list(map(int,input().split()))
temp.append(i)
time.append(temp)
time.sort()
j1s=0
j1e=0
c1s=0
c1e=0
flag1=0
result=[0]*n1
for i in range(n1):
f11=0
f12=0
if (time[i][0]>=j1s and time[i][0]<j1e) or (time[i][1]>j1s and time[i][1]<=j1e):
f11=1
if (time[i][0]>=c1s and time[i][0]<c1e) or (time[i][1]>c1s and time[i][1]<=c1e):
f12=1
if f11==0:
result[time[i][2]]='J'
j1s=time[i][0]
j1e=time[i][1]
elif f12==0:
result[time[i][2]]='C'
c1s=time[i][0]
c1e=time[i][1]
else:
flag1=1
break
if flag1==0:
answer="".join(result)
print("Case #%d: %s"%(x+1,answer))
else:
print("Case #%d: IMPOSSIBLE"%(x+1))
when is tutorial for 5th problem coming, i got WA
when is tutorial for 5th problem coming, i got WA