Codeforces 659B Qualifying Contest【模拟,读题】
写这道题题解的目的就是纪念一下半个小时才读懂题。。。英文一多读一读就溜号。。。
读题时还时要静下心来。。。
题目链接:
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【模拟,读题】的更多相关文章
- codeforces 659B Qualifying Contest
题目链接:http://codeforces.com/problemset/problem/659/B 题意: n个人,m个区.给出n个人的姓名(保证不相同),属于的区域,所得分数.从每个区域中选出成 ...
- Codeforces 61B【怪在读题】
搞不懂为什么DFS的写法崩了,然后乱暴力,因为题意不是很懂... 主要还是读题吧(很烦 #include <bits/stdc++.h> using namespace std; type ...
- Codeforces 438D (今日gg模拟第二题) | 线段树 考察时间复杂度的计算 -_-|||
Codeforces 438D The Child and Sequence 给出一个序列,进行如下三种操作: 区间求和 区间每个数模x 单点修改 如果没有第二个操作的话,就是一棵简单的线段树.那么如 ...
- Codeforces 631A Interview【模拟水题】
题意: 模拟模拟~~ 代码: #include<iostream> using namespace std; const int maxn = 1005; int a[maxn], b[m ...
- LeetCode 2 Add Two Numbers 模拟,读题 难度:0
https://leetcode.com/problems/add-two-numbers/ You are given two linked lists representing two non-n ...
- codeforces 659B B. Qualifying Contest(水题+sort)
题目链接: B. Qualifying Contest time limit per test 1 second memory limit per test 256 megabytes input s ...
- Codeforces Round #346 (Div. 2) B. Qualifying Contest 水题
B. Qualifying Contest 题目连接: http://www.codeforces.com/contest/659/problem/B Description Very soon Be ...
- Codeforces Round #346 (Div. 2) B Qualifying Contest
B. Qualifying Contest 题目链接http://codeforces.com/contest/659/problem/B Description Very soon Berland ...
- B. Qualifying Contest
time limit per test 1 second memory limit per test 256 megabytes input standard input output standar ...
随机推荐
- 洛谷 P1802 5倍经验日
题目背景 现在乐斗有活动了!每打一个人可以获得5倍经验!absi2011却无奈的看着那一些比他等级高的好友,想着能否把他们干掉.干掉能拿不少经验的. 题目描述 现在absi2011拿出了x个迷你装药物 ...
- (转)SpringMVC学习(十二)——SpringMVC中的拦截器
http://blog.csdn.net/yerenyuan_pku/article/details/72567761 SpringMVC的处理器拦截器类似于Servlet开发中的过滤器Filter, ...
- QT+常见控件+tab Widget 和Stacked Widget
首先:这里介绍以下tab Widget 和Stacked Widget 之间的区别和使用的方法: tab Widget控件可以直接的进行切换,Stacked Widget却不可以直接在界面上进行切换, ...
- OpenCV2:第五章 访问图像
一.行/列访问 1.单行/单列访问 Mat Mat::row(int i) const Mat Mat::col(int j) const 2.多行/多列访问 Range(start,end); Ra ...
- git 设置ss代理
git config --global https.proxy http://127.0.0.1:1080 git config --global https.proxy https:// ...
- Android UI: LinearLayout中layout_weight 属性的使用规则
首先来查看android sdk文档,有这么一段话 LinearLayout also supports assigning a weight to individual children with ...
- 字符数组函数,连接strcat 复制函数strcpy 比较函数strcmp 长度函数 strlen
之前我们学习数据类型的时候,有一个类型 char ,这个类型允许我们在里边放一个字符 char variable1='o'; char variable2='k'; #include <iost ...
- 苹果平台上的媒体流播放技术HLS
近日在和朋友聊起媒体流的服务器端实时转码技术的时候,发现苹果的各种终端上的视频播放并未使用常见的基于UDP的RTSP/RTP,而强制使用了Http Live Stream技术,这里稍稍总结了如下. 苹 ...
- python常用模块之sys, os, random
一. sys模块 1. 作用: sys模块是与python解释器交互的一个接口 2. 具体使用 1. sys.argv 获取当前正在执行的命令行列表, 第一个为程序本身路径 print('file n ...
- UVALive - 6275 Joint Venture (二分)
题意: 给定一个整数w, 然后给定n个数, 问有没有两个数之和恰好为w 分析: 现将n个数数组a[]排序, 然后用两个变量i,j指向开头和末尾, 如果a[i] + a[j] > w, i++, ...