Problem C
Guessing Camels
One of the most interesting bets involves guessing the complete order in which the camels will finish the race. This bet offers the biggest return on your money, since it is also the one that is the hardest to get right.
Jaap, Jan, and Thijs have already placed their bets, but the
race will not start until an hour from now, so they are getting
bored. They started wondering how many pairs of camels they
have put in the same order. If camel
Input
The input consists of:
-
one line with an integer
( ), the number of camels; -
one line with
integers ( for all ), Jaap’s bet. Here is the camel in the first position of Jaap’s bet, is the camel in the second position, and so on; -
one line with Jan’s bet, in the same format as Jaap’s bet;
-
one line with Thijs’ bet, in the same format as Jaap’s bet.
The camels are numbered
Output
Output the number of pairs of camels that appear in the same
order in all
Sample Input 1 | Sample Output 1 |
---|---|
3 3 2 1 1 2 3 1 2 3 |
0 |
Sample Input 2 | Sample Output 2 |
---|---|
4 2 3 1 4 2 1 4 3 2 4 3 1 |
3 |