DECODE IT

All submissions for this problem are available.
$Ajju$ $bhai$ is tired of coding. One day he decides to go on a treasure hunt. He founds the treasure but it is locked with a $N$ sided $polygon$ shaped lock. To open the lock one needs to generate the $passcode$. The procedure to generate the $passcode$ is as follows : There are $N$ alphabets (not necessarily distinct) with a particular numerical value assigned to it in random order on each edge of a $polygon$. Now suppose a particular numerical value $S$ is of $d$ digits. Now add up all the digits in $S$ until a $single$ digit number is generated. For example let the value of $S$ is $2345$, adding up the digits we get $14$ which is a $two$ digit number. So again adding up the digits we get $5$, which a $single$ digit number. The $single$ digit number thus generated will be the new value for a particular edge. Now arrange them in a non  decreasing order with respect to characters. In case if the characters are equal then arrange them in non decreasing order of their respective numerical values. After performing this operation, take the $XOR$ of $k$ consecutive numerical values starting from the first edge and add them up to generate a number $P$ which will be the $passcode$ to open the lock. $k$ is $half$ the count of total number of $distinct$ $diagonals$ that can be drawn in the given $polygon$ such that no two $diagonals$ cut / intersect each other. As $Ajju$ $bhai$ is already tired while searching the treasure, you are the only one who can help him! ###Note :  The nature of the $polygon$ is always $convex$.  The $diagonals$ may intersect at a vertex.  Large input file, Use $fastio.$ ###Input:  Firstline will contain $T$, the number of test cases. Then the test cases follow.  Each test case contains three lines of input.  Firstline contains the value of $N$, the number of edges of $polygon$.  Secondline contains $N$ size array $C$ which contains space  separated alphabet characters.  The third line contains $N$ size array $B$ which contains corresponding space  separated numerical values associated with each of $N$ alphabets. ###Output: For each test case, output in a single line the value of the $passcode$. ###Constraints  $1 \leq T \leq 1000$  $7 \leq N\leq 10^5$  $a \leq C[i]\leq z$  $0 \leq B[i]\leq 10^X$  $0 \leq X \leq 10^5$  $\sum_{i=1}^{n} L_{i} < 10^8 $ where $L_{i}$ is length of $B[i]$ ###Sample Input: 1 8 a b c d e f g h 11 12 13 14 15 16 17 18 ###Sample Output: 29 ###EXPLANATION: The new values for the edges will be 2, 3, 4, 5, 6, 7, 8, 9. The alphabets are already in non  decreasing order. Here the value of k = 2. So adding up all the k consecutive values XORs, 2^3 + 3^4 + 4^5 + 5^6 + 6^7 + 7^8 + 8^9 = 29, which is our required answer.Author:  shrey0304 
Tags  shrey0304 
Date Added:  18122019 
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. 