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 ...
随机推荐
- (十五)mybatis 逆向工程
目录 为什么需要逆向工程 使用方法 如何读懂生成的代码 总结 为什么需要逆向工程 对于数据库中的那么多的表 ,基本的 CRUD 操作 ,以及 mybatis 需要使用的 接口.mapper ,这些工作 ...
- Python中的幽灵—编码方式
首先要搞懂本地操作系统编码与系统编码的区别: 本地操作系统编码方式与操作系统有关,Linux默认编码方式为utf-8,Windows默认编码方式为gbk: 系统编码方式与编译器or解释器有关,Pyth ...
- Linux 创建用户 用户组 用户权限
首先 你要有个root账号 然后才能做下面几条操作: useradd username 创建用户usernamepasswd user_pwd 给已创建的用户username设置密码 关于us ...
- 怎样使用yum安装nginx
yum install -y nginx 以上.
- Oracle导入数据后中文乱码的解决方法
解决方法: 方法一. 1.在运行命令行输入regedit,打开注册表编辑器 2.找到HKEY_LOCAL_MACHINE\SOFTWARE\ORACLE\KEY_OraDb11g_home1 3.看N ...
- XML模块与类的定义
xml模块 xml介绍: --XML 全称 可扩展标记语言 --<tag></tag> 双标签 标签中间可以加入文本信息 --<tag/>单标签 没有文本 ...
- bootstrap-selectpicker 插件事件
$('#id').on('show.bs.select', function (e) { //绑定下拉显示列表触发事件 }); $('#id').on('hidden.bs.select', func ...
- CSS精灵技术(sprite)
CSS技术的使用场景:有效的减少了服务器接收和发送请求的次数,css精灵是一种出来网页背景图像的方式,将一个页面设计到的所有零星背景图集中到一张大图中去,然后将大图应用于网页 .通过backgroun ...
- Nginx如何配置基础缓存
// /path/to/cache/:用于缓存的本地磁盘目录 // levels :在 /path/to/cache/ 设置了一个两级层次结构的目录. // 将大量的文件放置在单个目录中会导致文件访问 ...
- ORACLE_笔记_练习题目
一.plsql用法网址及时复习 extract()函数----用于截取年.月.日.时.分.秒 https://www.cnblogs.com/xqzt/p/4477239.html case when ...