Codeforces Round #346 (Div. 2) B题
B. Qualifying Contest
Very soon Berland will hold a School Team Programming Olympiad. From each of the m Berland regions a team of two people is invited to participate in the olympiad. The qualifying contest to form teams was held and it was attended by n Berland students. There were at least two schoolboys participating from each of the m regions of Berland. The result of each of the participants of the qualifying competition is an integer score from 0 to 800 inclusive.
The team of each region is formed from two such members of the qualifying competition of the region, that none of them can be replaced by a schoolboy of the same region, not included in the team and who received a greater number of points. There may be a situation where a team of some region can not be formed uniquely, that is, there is more than one school team that meets the properties described above. In this case, the region needs to undertake an additional contest. The two teams in the region are considered to be different if there is at least one schoolboy who is included in one team and is not included in the other team. It is guaranteed that for each region at least two its representatives participated in the qualifying contest.
Your task is, given the results of the qualifying competition, to identify the team from each region, or to announce that in this region its formation requires additional contests.
Input
The first line of the input contains two integers n and m (2 ≤ n ≤ 100 000, 1 ≤ m ≤ 10 000, n ≥ 2m) — the number of participants of the qualifying contest and the number of regions in Berland.
Next n lines contain the description of the participants of the qualifying contest in the following format: Surname (a string of length from 1 to 10 characters and consisting of large and small English letters), region number (integer from 1 to m) and the number of points scored by the participant (integer from 0 to 800, inclusive).
It is guaranteed that all surnames of all the participants are distinct and at least two people participated from each of the m regions. The surnames that only differ in letter cases, should be considered distinct.
Output
Print m lines. On the i-th line print the team of the i-th region — the surnames of the two team members in an arbitrary order, or a single character "?" (without the quotes) if you need to spend further qualifying contests in the region.
Input
Ivanov
Andreev
Petrov
Sidorov
Semenov
Output
Sidorov Ivanov
Andreev Semenov
Input
Ivanov
Andreev
Petrov
Sidorov
Semenov
Output
?
Andreev Semenov
心得:学会了vector中套结构体。。。。。。。。。。。
AC代码:
#include<bits/stdc++.h> using namespace std;
#define endl '\n'
#define N 100009
struct str{
string name;
int team;
int score;
};
vector<str> v[N];
bool cmp(str a,str b){
return a.score>b.score;
}
int main(){
int n,m;
cin>>n>>m;
struct str temp;
for(int i=;i<=n;i++){
cin>>temp.name>>temp.team>>temp.score;
v[temp.team].push_back(temp);
}
for(int i=;i<=m;i++){
sort(v[i].begin(),v[i].end(),cmp);
if(v[i].size()==){
puts("?");
}else if(v[i].size()==){
cout<<v[i][].name<<" "<<v[i][].name<<endl;
}else{
if(v[i][].score==v[i][].score){
puts("?");
}else{
cout<<v[i][].name<<" "<<v[i][].name<<endl;
}
}
}
return ;
}
Codeforces Round #346 (Div. 2) B题的更多相关文章
- Codeforces Round #346 (Div. 2) A题 [一道让我生气的思维题·]
		A. Round House Vasya lives in a round building, whose entrances are numbered sequentially by integer ... 
- Codeforces Round #346 (Div. 2) E题 并查集找环
		E. New Reform Berland has n cities connected by m bidirectional roads. No road connects a city to it ... 
- Codeforces Round #346 (Div. 2) C题
		C. Tanya and Toys In Berland recently a new collection of toys went on sale. This collection consist ... 
- Codeforces Round #346 (Div. 2)---E. New Reform--- 并查集(或连通图)
		Codeforces Round #346 (Div. 2)---E. New Reform E. New Reform time limit per test 1 second memory lim ... 
- Codeforces Round #378 (Div. 2) D题(data structure)解题报告
		题目地址 先简单的总结一下这次CF,前两道题非常的水,可是第一题又是因为自己想的不够周到而被Hack了一次(或许也应该感谢这个hack我的人,使我没有最后在赛后测试中WA).做到C题时看到题目情况非常 ... 
- Codeforces Round #612 (Div. 2) 前四题题解
		这场比赛的出题人挺有意思,全部magic成了青色. 还有题目中的图片特别有趣. 晚上没打,开virtual contest打的,就会前三道,我太菜了. 最后看着题解补了第四道. 比赛传送门 A. An ... 
- Codeforces Round #713 (Div. 3)AB题
		Codeforces Round #713 (Div. 3) Editorial 记录一下自己写的前二题本人比较菜 A. Spy Detected! You are given an array a ... 
- Codeforces Round #552 (Div. 3) A题
		题目网址:http://codeforces.com/contest/1154/problem/ 题目意思:就是给你四个数,这四个数是a+b,a+c,b+c,a+b+c,次序未知要反求出a,b,c,d ... 
- Codeforces Round #412  Div. 2 补题 D. Dynamic Problem Scoring
		D. Dynamic Problem Scoring time limit per test 2 seconds memory limit per test 256 megabytes input s ... 
随机推荐
- SSM框架的整合与使用——实现简单的转账系统
			一.整合思路 SSM框架即SpringMVC + Spring + MyBati框架集,是一种轻量级的Web开源框架.它们各自在JAVA三层架构中负责的模块如下图所示: 其中,SpringMVC与Sp ... 
- ubuntu 拨号上网
			如果没有安装的用户,可以使用 sudo apt-get install pppoe pppoeconf 然后配置上网 sudo pppoeconf 最后,使用 sudo pon dsl-provide ... 
- Python中几个必须知道的函数
			Python中自带了几个比较有意思的函数,一般在面试或者笔试基础的时候会问到,其中3个就是map.filter.reduce函数. 1.map(function, iterable) 它第一个要传的元 ... 
- Pygame小游戏练习五
			@Python编程从入门到实践 Python项目练习 十一.显示游戏得分及最高分 创建新类Scoreboard,用以显示得分和最高分. # scoreboard.py import pygame.fo ... 
- windows系统 MySQL8.0.12详细安装步骤及基本使用教程
			转载 https://blog.csdn.net/xiezhiming1234/article/details/82860339 
- 使用canal获取mysql的binlog传输给kafka,并交由logstash获取实验步骤
			1. 实验环境 CPU:4 内存:8G ip:192.168.0.187 开启iptables防火墙 关闭selinux java >=1.5 使用yum方式安装的java,提前配置好JAVA_ ... 
- javascript中用&&跟||来简化if{}else{}的写法
			原文:javascript中用&&跟||来简化if{}else{}的写法 目录 javascript中用&&跟||来简化if{}else{}的写法 1. if else ... 
- 关于工作单元模式——工作单元模式与EF结合的使用
			工作单元模式往往和仓储模式一起使用,本篇文章讲到的是工作单元模式和仓储模式一起用来在ef外面包一层,其实EF本身就是工作单元模式和仓储模式使用的经典例子,其中DbContext就是工作单元,而每个Db ... 
- 函数——箭头函数&自执行函数(二)
			一.箭头函数是在es6中添加的一种规范,它相当于匿名函数,简化了函数的定义. 1.语法 a.function用var,let,cost来表示: b.参数要写在第一个等号后面: 参数有多个,需要加一 ... 
- 1  简介mvp模式
			1 模型-视图-表示器也称为监视控制器模式 ,如下图表示 2 mvp 模式希望通过表示器(presenter)来关联网页,而不必在他们之间建立严格的 3 一个简单的mvp架构的例子 public ... 
