When History Offers a Hand

All submissions for this problem are available.
Cooper is trying to decipher the strange dust patterns in Murphy’s room. He observes that there are two patterns repeating, and he decides to write them as binary strings having ‘a’ and ‘b’. He now obtains two strings of equal length $N$, where $N$ is even. Now to process this, he needs to make both the strings palindromic, which he wants you to do. He thus gives you the strings. You are given two strings of equal length $N$, where $N$ is even. Every character in each string has only two possible characters, ‘a’ or ‘b’. You have at most $N1$ operations of the form $x_0$ $x_1$ $x_2$. This means:  If $x_0=1$, swap the $x_1^{th}$ and $x_2^{th}$ characters of string 1.  If $x_0=2$, swap the $x_1^{th}$ character of string 1 and $x_2^{th}$ character of string 2.  If $x_0=3$, swap the $x_1^{th}$ and $x_2^{th}$ character of string 2. For example if the operation is $1$ $5$ $4$, swap the 5th character of string 1 and the 4th character of string 1. You either have to use these operations to make both the strings palindromic or report that such a transformation is not possible and conclude that the strange dust pattern did not mean anything. ###Input Format  The first line of the input contains $T$, the number of test cases.  In each test case, the first line has $N$, the number of letters in each string.  The next two lines contain the two strings. ###Constraints  $1 \leq T \leq 100$  $2 \leq N \leq 50$, $N$ is even ###Output Format  For each test case, print several lines.  If the transformation is not possible, print a line containing 1.  Else, print on the first line the number of needed operations.  In each of the next lines, print a sequence of integers $x_0$ $x_1$ $x_2$.  Note that you do not have to minimize the number of operations.  If there are multiple solutions, you may print any. ###Sample Input 2 6 aabaaa baabba 6 aaaaaa bbbbba ###Sample Output 2 2 4 1 3 5 3 1Author:  shriram_c253 
Tags  shriram_c253 
Date Added:  19122019 
Time Limit:  1 sec 
Source Limit:  50000 Bytes 
Languages:  C, CPP14, JAVA, PYTH, PYTH 3.6, PYPY, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, rust, SCALA, swift, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, ERL, TCL, SQL, kotlin, PERL6, TEXT, SCM chicken, PYP3, CLOJ, R, COB, FS 
Comments
 Please login at the top to post a comment.
SUCCESSFUL SUBMISSIONS
Fetching successful submissions
HELP
If you are still having problems, see a sample solution here. 