2306: Marriage
| Result | TIME Limit | MEMORY Limit | Run Times | AC Times | JUDGE |
|---|---|---|---|---|---|
| 3s | 8192K | 503 | 73 | Standard |
Now, a lot of persons holding their marriages together are in fashion. One day, a lot of people hold their marriages together. They are all happy, so they want to play a game. They stand in two lines, one faces one. The men are in one line, the women are in another. They stand arbitrarily. Then, there will be some red lines to link each couple. So can you calculate how many pairs of the red lines are overlaped.
Input
There are several cases in the input, each case begin with a postive integer N(N<=300000), which means there are N couples, 0 means the end of the file. The following 2 lines each consists of N integers. Each integer represents a couple. The first line are men, the second are women.Output
For each case output how many pairs of lines are overlaped.
Sample Input
31 2 3
3 2 1
3
1 2 3
1 2 3
0
Sample Output
0
本文介绍了一种通过连线游戏来计算婚礼中情侣连线交叉次数的算法。游戏中参与者分为两排面对面站立,通过随机连线形成情侣对,并计算这些线段间的交叉数目。输入包括情侣对的数量及每对情侣的身份标识,输出则是所有线段的交叉总数。
1594

被折叠的 条评论
为什么被折叠?



