I had a different approach to solving this problem. I generated all the
possible orthogonal latin squares of all possible sizes and for every size
cached the mattrices based on their trace. So that way it was like. Now for
1 to 50 this thing is done in less than 3 seconds and now all you have to
do is read the input, check if the keys pair exists and print the answer. I
do not have any idea why it wasn't accepted. Can anyone tell where was I
missing the corner case?
{
"1": {},
"2": {
"2": [[ 1, 2],
[ 2, 1]]
},
"3": {
"3": [[ 1, 2, 3],
[ 3, 1, 2],
[ 2, 3, 1]],
"6": [[ 1, 2, 3],
[ 2, 3, 1],
[ 3, 1, 2]]
},
"4": {
"4": [[ 1, 2, 3, 4],
[ 4, 1, 2, 3],
[ 3, 4, 1, 2],
[ 2, 3, 4, 1]],
"8": [[ 1, 2, 3, 4],
[ 2, 3, 4, 1],
[ 3, 4, 1, 2],
[ 4, 1, 2, 3]],
"10": [[ 1, 2, 3, 4],
[ 3, 4, 1, 2],
[ 1, 2, 3, 4],
[ 3, 4, 1, 2]]
}
}
--
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/862aff34-6498-41c5-8912-dd662dbb2169%40googlegroups.com.