Hi Andre, I had the same solution written in c++.
Check for squared matrices with even order (r==c and r%2==0, like 4x4), specifically for placement on last column. Hope it helps, Juarez Paulino On Thu, Apr 18, 2019 at 2:26 PM 'André Bienemann' via Google Code Jam < [email protected]> wrote: > Hi guys, > > I'm trying to solve the problems from the last round and I'm currently > stuck on the first problem. I came up with the code shown below, and it > finds the path without violating the given constraints, but the system says > that the answer is wrong. Does anyone see what's wrong with my code? Thanks > in advance! > > t = int(input()) > for i in range(1, t + 1): > r, c = [int(n) for n in input().split()] > if r * c < 10 or r < 2 or c < 2: > print('Case #{}: IMPOSSIBLE'.format(i)) > else: > print('Case #{}: POSSIBLE'.format(i)) > s, b, k = 0, 0, 3 if r == 2 or c == 2 else 2 > if c >= r: > for _ in range(0, c): > for j in range(0, r): > p = j + 1 > q = (s + k if b else s) % c + 1 > print('{} {}'.format(p, q)) > b ^= 1 > s, b = s + 1, 0 > else: > for _ in range(0, r): > for j in range(0, c): > p = (s + k if b else s) % r + 1 > q = j + 1 > print('{} {}'.format(p, q)) > b ^= 1 > s, b = s + 1, 0 > > -- > 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/bea43a97-c1c8-4b4c-8713-8eb0d2c8088b%40googlegroups.com > . > For more options, visit https://groups.google.com/d/optout. > -- 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/CANGQpYzXzsU45td9onG6MCA_Oa7GE3e5cbjstWjpvDtZrzQHiQ%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
