Hello, I'm trying to solve the 3. task of the qualification round 2020.
I'm using Python3 to solve this problem.
When I'm submiting my code it says "Sample Failed: WA".
This is my code:
number_of_cases = int(input())
for case_number in range(1, number_of_cases + 1):
appointments = int(input())
dates = []
solution = ""
J_works_till, C_works_till = 0, 0
possible = True
# collect the time
for appointment in range(appointments):
dates.append(list(map(int, input().split(" "))))
# Sort the dates
dates = sorted(dates, key=lambda x: x[0])
for date in dates:
# Can Jamie handle the task?
if J_works_till <= date[0]:
J_works_till = date[1]
solution += "J"
# Can Cameron handle the task?
elif C_works_till <= date[0]:
C_works_till = date[1]
solution += "C"
# Nope
else:
possible = False
break
if possible:
print("Case #%d: %s" % (case_number, solution))
else:
print("Case #%d: IMPOSSIBLE" % case_number)
I tried the examples of the task and I'm getting the following output:
Case #1: JCJ
Case #2: IMPOSSIBLE
Case #3: JCCJC
Case #4: JJ
As you can see, my third solution is a little bit different than in the
examples (there's "JCCJJ"). I tried to compare it with the times but it
seems to be fine (or I was just stupid).
If not, do you have an idea what I'm doing wrong?
Sorry for my bad english... I hope that you can still understand me ;-;
Cheers!
--
You received this message because you are subscribed to the Google Groups
"Google Code Jam" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/google-code/39bddc1a-b32e-4336-8c95-eb80498b40b1%40googlegroups.com.