Hello folks, I would like to get a hint on what's going wrong with my code 
below, I chose a brute-force approach but something is preventing successful 
submission...
Thanks in advance for the hint... Here's my code:

# Read the test set length
length = input()

rows = []

for case in range(length):
    # Read the test case...
    rows.append(raw_input())

count = 0

# Check each case...
for i in rows:
    result = 'IMPOSSIBLE'
    count += 1
    r, c = int(i.split(' ')[0]), int(i.split(' ')[1])

    # Galaxy roundtrip
    roundtrip = []
    for rr in range(1, r+1):
        for rc in range(1, c+1):
            roundtrip.append((rr, rc))

    # Starting point...
    for ir, ic in roundtrip:
        ar, ac = ir, ic
        visited = []
        visited.append((ar, ac))

        # Consider the actual position and...
        for _ in range(r*c):

            # ...Try to jump from there.
            for pr, pc in roundtrip:
                if not (pr == ar or pc == ac or pr - pc == ar - ac 
                         or pr + pc == ar + ac or (pr, pc) in visited):
                    ar, ac = pr, pc
                    visited.append((pr, pc))

        # Stop... or not
        if len(visited) == r*c:
            result = 'POSSIBLE'
            break

    # Output
    print('Case #' + str(count) + ': ' + result)
    if result == 'POSSIBLE':
        for rp, cp in visited:
            print('\n' + str(rp) + ' ' + str(cp))

-- 
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 post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/google-code/4dbbc9cc-c2f2-43b2-a925-dd9b3e4301cd%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to