-
Notifications
You must be signed in to change notification settings - Fork 0
/
Parenting Partnering Returns
64 lines (63 loc) · 1.54 KB
/
Parenting Partnering Returns
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
t = int(input())
i = 0
while(i<t):
start = list()
end = list()
start_1 = list()
n = int(input())
J = -1
C = -1
s_1 = list()
s_2 = list()
imp = 0
s=""
for j in range(n):
ele = input()
a = ele.split(" ")
start_1.append(int(a[0]))
if(j == 0):
start.append(int(a[0]))
end.append(int(a[1]))
else:
for k in range(len(start)):
if(int(a[0])<start[k]):
start.insert(k,int(a[0]))
end.insert(k,int(a[1]))
break
elif(k == len(start)-1):
start.append(int(a[0]))
end.append(int(a[1]))
for k in range(len(start)):
if(k==0):
J=k
s_1.append(start_1.index(start[k]))
else:
if(start[k]<end[J]):
if(start[k]>=end[C] or C==-1):
C=k
s_2.append(start_1.index(start[k]))
else:
imp = 1
break
elif(start[k]>=end[J]):
J=k
s_1.append(start_1.index(start[k]))
i+=1
if(imp == 1):
print("Case #%d: IMPOSSIBLE"%(i))
imp = 0
else:
temp = 0
while(temp<n):
if(temp in s_1):
s += "J"
else:
s += "C"
temp += 1
print("Case #%d:"%(i),s)
start.clear()
end.clear()
start_1.clear()
s_1.clear()
s_2.clear()
s=""