写这道题题解的目的就是纪念一下半个小时才读懂题。。。英文一多读一读就溜号。。。

读题时还时要静下心来。。。


题目链接:

http://codeforces.com/contest/659/problem/B

题意:

给定地区及来自相应地区的人的分数,每个地区选两个分数最高的人 参加区域赛,如果选出的两个人唯一,则输出名字,否则如果还需要进行下一次比赛,输出“?”。

分析:

不唯一的情况就是第二个人和第三个人的分数相同嘛。。。排个序找一下就好了。

代码:

#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 5;
struct Node{string s; int sc;};
Node node[maxn];
int num[maxn];
vector<Node>v[maxn];
bool cmp(Node a, Node b)
{
return a.sc >b.sc;
}
int main (void)
{
int n, m;
cin>>n>>m;
string s;
int id, score;
for(int i = 0; i <n; i++){
cin>>s>>id>>score;
node[i] = (Node){s, score};
v[id].push_back(node[i]);
num[id]++;
}
for(int i = 1; i <= m; i++){
sort(v[i].begin(), v[i].end(), cmp);
if(v[i].size() > 2 && v[i][2].sc == v[i][1].sc) cout<<"?"<<endl;
else cout<<v[i][0].s<<' '<<v[i][1].s<<endl;
}
return 0;
}

Codeforces 659B Qualifying Contest【模拟,读题】的更多相关文章

  1. codeforces 659B Qualifying Contest

    题目链接:http://codeforces.com/problemset/problem/659/B 题意: n个人,m个区.给出n个人的姓名(保证不相同),属于的区域,所得分数.从每个区域中选出成 ...

  2. Codeforces 61B【怪在读题】

    搞不懂为什么DFS的写法崩了,然后乱暴力,因为题意不是很懂... 主要还是读题吧(很烦 #include <bits/stdc++.h> using namespace std; type ...

  3. Codeforces 438D (今日gg模拟第二题) | 线段树 考察时间复杂度的计算 -_-|||

    Codeforces 438D The Child and Sequence 给出一个序列,进行如下三种操作: 区间求和 区间每个数模x 单点修改 如果没有第二个操作的话,就是一棵简单的线段树.那么如 ...

  4. Codeforces 631A Interview【模拟水题】

    题意: 模拟模拟~~ 代码: #include<iostream> using namespace std; const int maxn = 1005; int a[maxn], b[m ...

  5. LeetCode 2 Add Two Numbers 模拟,读题 难度:0

    https://leetcode.com/problems/add-two-numbers/ You are given two linked lists representing two non-n ...

  6. codeforces 659B B. Qualifying Contest(水题+sort)

    题目链接: B. Qualifying Contest time limit per test 1 second memory limit per test 256 megabytes input s ...

  7. Codeforces Round #346 (Div. 2) B. Qualifying Contest 水题

    B. Qualifying Contest 题目连接: http://www.codeforces.com/contest/659/problem/B Description Very soon Be ...

  8. Codeforces Round #346 (Div. 2) B Qualifying Contest

    B. Qualifying Contest 题目链接http://codeforces.com/contest/659/problem/B Description Very soon Berland ...

  9. B. Qualifying Contest

    time limit per test 1 second memory limit per test 256 megabytes input standard input output standar ...

随机推荐

  1. Keil简介

    最早接触Keil是学习开发8051系列的单片机.Keil C51是Keil公司出品的51系列兼容单片机C语言软件开发系统,与汇编相比,C语言在功能上.结构性.可读性.可维护性上有明显的优势,因而易学易 ...

  2. 第8章 应用协议 图解TCP/IP 详解

    第8章 应用协议 图解TCP/IP 详解 8.1 应用层协议概要 应用层协议的定义 TCP和IP等下层协议是不依赖上层应用类型.实用性非常广的协议.而应用协议则是为了实现某种应用而设计和创造的协议. ...

  3. redis源码分析之事务Transaction(下)

    接着上一篇,这篇文章分析一下redis事务操作中multi,exec,discard三个核心命令. 原文地址:http://www.jianshu.com/p/e22615586595 看本篇文章前需 ...

  4. DROP TRIGGER - 删除一个触发器定义

    SYNOPSIS DROP TRIGGER name ON table [ CASCADE | RESTRICT ] DESCRIPTION 描述 DROP TRIGGER 将删除所有对一个现存触发器 ...

  5. iview table 已选项的数据 this.$refs.tables.$refs.tablesMain.getSelection()

    iview table 已选项的数据 this.$refs.tables.$refs.tablesMain.getSelection() 由于我这里table组件是套了两层组件 所以是进入了两个层次拿 ...

  6. axios token header response request http拦截器 axios实现登录、拦截、登出

    axios token header response request http拦截器 axios实现登录.拦截.登出 一个项目学会前端实现登录拦截 https://github.com/superm ...

  7. 日常[splay]:水题记——普通平衡树(死亡调试)

    普通平衡树,模板的不能再模板的模板题.我调了两个小时... 早先看yyb大神的blog学习splay,看的风生水起然而没有发现,大神的坑没有填……没有rank操作和k_th操作. 只能自己摸索,问问大 ...

  8. IntelliJ IDEA使用eclipse compiler(ecj)解决lombok编译问题

    1:为什么要使用在idea使用eclipse compiler(ecj)? 因为idea默认使用javac,而javac当在编译时发现一个编译错误就直接停止编译了.而ecj支持proceed on e ...

  9. 02.28 day03

    print(1 or 3 > 2 and 4 < 5 or 6 and 2 < 7)## while True:# print(11)# print(22)# # break# # ...

  10. 定位 absolute和relative比较

    absolute:脱离原来位置定位.是相对于最近的有定位的父级进行定位;如果没有有定位的父级元素,就相对文档进行定位 relative:保留原来位置进行定位,相对于自己原来的位置进行定位 下面举两个例 ...