题目:https://codeforces.com/contest/1552/problem/B
#include<vector>
#include<iostream>
using namespace std;
const int maxn = 5e4 + 5;
struct node
{
int a, b, c, d, e;
int num;
};
node a[maxn];
int Compete(node x, node y)
{
int scx = 0, scy = 0;
if (x.a < y.a) { scx++; }
else { scy++; }
if (x.b < y.b) { scx++; }
else { scy++; }
if (x.c < y.c) { scx++; }
else { scy++; }
if (x.d < y.d) { scx++; }
else { scy++; }
if (x.e < y.e) { scx++; }
else { scy++; }
if (scx >= scy) { return 1; }
else { return 0; }
}
int main()
{
int T;
cin >> T;
while (T--)
{
int n;
cin >> n;//How many is the sportsman
for (int i = 1; i <= n; i++)
{
cin >> a[i].a >> a[i].b >> a[i].c >> a[i].d >> a[i].e;
a[i].num = i;
}
int win = 1;
int i = 1, j = 2;
while (i <= n && j <= n)
{
//Compare in turn
if (Compete(a[i], a[j]))
{
win = i;
j++;
}
else
{
win = j;
i = j;
j++;
}
}
bool ok = 1;
for (int i = 1; i <= n; i++)
{
if (i == win) { continue; }
//if one can not win the one
if (!Compete(a[win], a[i]))
{
ok = 0;
break;
}
}
if (ok)
{
cout << win << endl;
}
else
{
cout << -1 << endl;
}
}
return 0;
}