U161434求助
  • 板块灌水区
  • 楼主cygnus_beta
  • 当前回复2
  • 已保存回复2
  • 发布时间2021/5/7 20:24
  • 上次更新2023/11/4 23:34:44
查看原帖
U161434求助
452531
cygnus_beta楼主2021/5/7 20:24
#include<map>
#include<cstdio>
#include<iostream>
#include<vector>
using namespace std;

map<int,int>people;
vector<pair<int,int> >frs;
pair<int,int>p;
int ma;

inline bool exist(){
	for(vector<pair<int,int> >::iterator iter=frs.begin();iter!=frs.end();iter++)
		if((iter->first==p.first && iter->second==p.second) or (iter->second==p.first && iter->first==p.second))return true;
	return false;
}

signed main(){
    scanf("%d%d",&p.first,&p.second);
	while(scanf("%d%d",&p.first,&p.second)!=EOF)
		if(!exist()){
			frs.push_back(p);
			people[p.first]++;
			people[p.second]++;
		}
	for(map<int,int>::iterator iter=people.begin();iter!=people.end();iter++)ma=max(ma,iter->second);
	for(map<int,int>::iterator iter=people.end();iter!=people.begin();iter--)
		if(ma==iter->second){
			printf("%d",iter->first);
			break;
		}

	return 0;
}

开O2最后一个点爆TLE,不开5~10全爆

2021/5/7 20:24
加载中...