| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 813 人关注过本帖
标题:帮忙看一下,这个题意怎么也看不明白
取消只看楼主 加入收藏
枫叶无痕
Rank: 2
等 级:论坛游民
帖 子:80
专家分:30
注 册:2011-2-10
结帖率:73.91%
收藏
已结贴  问题点数:20 回复次数:1 
帮忙看一下,这个题意怎么也看不明白
Measuring Problem Difficulty

Time Limit:5000MS  Memory Limit:65536K
Total Submit:14 Accepted:3

Description

If you are the lucky one to advance to the ACM-ICPC World Finals, one of the situations you will face is the world finals competition itself. Wait, isn’t that the main reason to go there? In the beginning of each ACM-ICPC competition, there are two separate goals each team tries to accomplish:
1. among the given set of problems, find the easiest one,
2. solve that problem as fast as possible.
To evaluate the performance of all teams in detail, we want to test your abilities for each of these two goals separately. This problem deals with the former goal (finding the easiest problem), the latter one (solving it) is analyzed in another problem (easy).
The main trouble with comparing problem difficulty is that the opinions of different people may vary. To satisfy everyone, we need to find some consensus. Let’s start with determining all problems on which the opinions agree.
Your team is given a set of ICPC problems. Each team member sorts all of the problems in the order of their expected difficulty. Then we want to find all pairs of problems such that their relative order is the same according to all given orderings.

Input

The input contains several tasks. Each task starts by one line containing single integer N, 2 ≤ N ≤ 150 000, the number of problems to consider.
After that, there are three blocks, each of them describing opinion of one team member. (ICPC teams have three members, right?) Every block specifies an arbitrary permutation of N numbers 1 . . .N representing the problems. You should know from the school that the word “permutation” means each of the numbers will appear exactly once in each block.
Each block starts on a new line. For presentation reasons, the numbers inside a block may be split among any number of lines. If there are more than one number per line, they will be separated by at least one space. Empty lines may occur before and after blocks.
The last task is followed by a line containing zero.

Output

For each task, print one line containing a single integer number: the number of all pairs of problems, whose mutual order is the same in all three permutations.
Please note that the result may be as high as N·(N−1)/2 and may therefore exceed 2^32.

Sample Input


4
1 2 3 4
2 3 4 1
4 1 2 3

6
3 6 1 2 4 5
3 6 1 4 2 5
3 6 1 2 4 5

0
Sample Output


1
14
搜索更多相关主题的帖子: face beginning problems separate Memory face beginning problems separate Memory 
2011-08-15 15:27
枫叶无痕
Rank: 2
等 级:论坛游民
帖 子:80
专家分:30
注 册:2011-2-10
收藏
得分:0 
回复 3楼 beyondyf
这个是超时的,方法我也是这个,但是。。。我想应该得用其他的方法
2011-08-15 17:36
快速回复:帮忙看一下,这个题意怎么也看不明白
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.012327 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved