Hi all,
My solution for this problem is given below . I don't know for which inputs
my solution went wrong ,i tried many test cases ( even and 2<=n<=16) but I
couldn't find where my code went wrong . Please help me in finding test
cases for which my solution went wrong (even cases) . Thanks in advance.
testcases=int(input())
for case in range(1,testcases+1):
n=int(input())
l=list(map(int,input().split()))
extra=0
if n%2==1:
extra=l[0];
l=l[1:]
n-=1
fin=[]
i=0
while i+1<n:
fin+=[[min(l[i],l[i+1]),max(l[i],l[i+1])]]
i+=2
fin.sort(key= lambda x : x[0])
if fin[0][0]%2==0:
lset=[fin[0][1]]
rset=[fin[0][0]]
else:
lset=[fin[0][0]]
rset=[fin[0][1]]
flag=0
for i in fin[1:]:
if i[0]%2==0:
if i[0]-1 in lset:
rset+=[i[0]]
lset+=[i[1]]
flag=1
else:
rset+=[i[1]]
lset+=[i[0]]
flag=1
else:
if i[0]+1 in lset:
rset+=[i[0]]
lset+=[i[1]]
flag=1
else:
rset+=[i[1]]
lset+=[i[0]]
flag=1
if flag==0:
lset+=[i[0]]
rset+=[i[1]]
else:
flag=0
if extra!=0:
if extra%2==0:
if extra-1 in lset:
rset+=[extra]
else:
lset+=[extra]
else:
if extra+1 in lset:
rset+=[extra]
else:
lset+=[extra]
res=['L' for i in range(n+1)]
else:
res=['L' for i in range(n)]
for i in rset:
res[i-1]='R'
if case < testcases:
print('Case #',case,": ","".join(res),sep="")
else:
print('Case #',case,": ","".join(res),sep="",end="")
--
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/d6f82f5a-3b19-4c16-b65c-bbcc2dcde67a%40googlegroups.com.