308647: CF1552B. Running for Gold
Memory Limit:256 MB
Time Limit:1 S
Judge Style:Text Compare
Creator:
Submit:0
Solved:0
Description
Running for Gold
题意翻译
### 【题目大意】 奥运比赛刚刚开始,Federico 便十分渴望观看比赛。 有 $n$ 个选手参加了马拉松比赛,从 $1$ 到 $n$ 依次编号。她们**都**参加了 $5$ 项比赛,比赛从 $1$ 到 $5$ 编号。 现在有一个二维的数组 $r_{i,j}(1 \leq i \leq n,1 \leq j \leq 5)$,表示选手 $i$ 在比赛 $j$ 中排名第 $r_{i,j}$ 名。 Federico 认为选手 $u$ 优于选手 $v$,当且仅当,$u$ 在**至少** $3$ 个项目中战胜了 $v$(即排名在 $v$ 前)。 Federico 认为选手 $x$ 能够获得金牌当且仅当 $x$ 可以战胜其它**所有**选手。 给定 $r_{i,j}$,求是否有一名选手可以获得金牌。 ### 【输入格式】 **多组数据**。 第一行 $T(1 \leq T \leq 1000)$,表示数据组数。 每组数据第一行 $n(1 \leq n \leq 50000)$,表示比赛数目。 接下来 $n$ 行,每行 $5$ 个数,表示 $r_{i, 1 \cdots 5}$。保证对于任意 $1 \leq j \leq 5$,$r_{1 \cdots n,j}$ 互不相同。 保证 $\sum n \leq 50000$。 ### 【输出格式】 每组数据输出一行,表示金牌得主。 **如果没有人能够获得金牌,则输出 `-1`**。 **如果有不止一个人可以获得金牌,输出任意即可**。 -------------------- Translated by @HPXXZYY.题目描述
The Olympic Games have just started and Federico is eager to watch the marathon race. There will be $ n $ athletes, numbered from $ 1 $ to $ n $ , competing in the marathon, and all of them have taken part in $ 5 $ important marathons, numbered from $ 1 $ to $ 5 $ , in the past. For each $ 1\le i\le n $ and $ 1\le j\le 5 $ , Federico remembers that athlete $ i $ ranked $ r_{i,j} $ -th in marathon $ j $ (e.g., $ r_{2,4}=3 $ means that athlete $ 2 $ was third in marathon $ 4 $ ). Federico considers athlete $ x $ superior to athlete $ y $ if athlete $ x $ ranked better than athlete $ y $ in at least $ 3 $ past marathons, i.e., $ r_{x,j}<r_{y,j} $ for at least $ 3 $ distinct values of $ j $ . Federico believes that an athlete is likely to get the gold medal at the Olympics if he is superior to all other athletes. Find any athlete who is likely to get the gold medal (that is, an athlete who is superior to all other athletes), or determine that there is no such athlete.输入输出格式
输入格式
The first line contains a single integer $ t $ ( $ 1 \le t \le 1000 $ ) — the number of test cases. Then $ t $ test cases follow. The first line of each test case contains a single integer $ n $ ( $ 1\le n\le 50\,000 $ ) — the number of athletes. Then $ n $ lines follow, each describing the ranking positions of one athlete. The $ i $ -th of these lines contains the $ 5 $ integers $ r_{i,1},\,r_{i,2},\,r_{i,3},\,r_{i,4},\, r_{i,5} $ ( $ 1\le r_{i,j}\le 50\,000 $ ) — the ranking positions of athlete $ i $ in the past $ 5 $ marathons. It is guaranteed that, in each of the $ 5 $ past marathons, the $ n $ athletes have distinct ranking positions, i.e., for each $ 1\le j\le 5 $ , the $ n $ values $ r_{1,j},\, r_{2, j},\, \dots,\, r_{n, j} $ are distinct. It is guaranteed that the sum of $ n $ over all test cases does not exceed $ 50\,000 $ .
输出格式
For each test case, print a single integer — the number of an athlete who is likely to get the gold medal (that is, an athlete who is superior to all other athletes). If there are no such athletes, print $ -1 $ . If there is more than such one athlete, print any of them.
输入输出样例
输入样例 #1
4
1
50000 1 50000 50000 50000
3
10 10 20 30 30
20 20 30 10 10
30 30 10 20 20
3
1 1 1 1 1
2 2 2 2 2
3 3 3 3 3
6
9 5 3 7 1
7 4 1 6 8
5 6 7 3 2
6 7 8 8 6
4 2 2 4 5
8 3 6 9 4
输出样例 #1
1
-1
1
5