#include<iostream>
#include<vector>
#include<iterator>
#include<algorithm>
using namespace std;
int main()
{
//n代表队伍,q代表比赛数目
int n, q;
cin >> n >> q;
vector<int> nn(n+1,0);
int a, b, c, d;
while (cin>>a>>b>>c>>d)
{
if (c > d)
{
nn[a] += 3;
nn[b] -= 2;
if (nn[b] < 0)
nn[b] = 0;
}
else if(c<d)
{
nn[b] += 3;
nn[a] -= 2;
if (nn[a] < 0)
nn[a] = 0;
}
else
{
;
}
}
vector<int>::iterator number = max_element(nn.begin(), nn.end());
cout << distance(nn.begin(), number);
return 0;
}
这里学习了一个函数
max_element(迭代器,迭代器)
返回两个迭代器范围内的元素的最大值所指向的迭代器
然后通过
distance(迭代器1,迭代器2)
计算迭代器2-迭代器1之间的元素个数,确定位置
其实也可以直接 number-nn.begin(),这点和迭代器的基本运算是一样的,很好理解