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 ...
随机推荐
- CentOS 7下安装配置proftpd搭建ftp服务器
proftpd全称:Professional FTP daemon,是针对Wu-FTP的弱项而开发的,除了改进的安全性,还具备许多Wu-FTP没有的特点,能以Stand-alone.xinetd模式运 ...
- uva12099 The Bookcase
这道题超经典.dp和优化都值得看一看.因为i+1只和i有关,用滚动数组节省空间暑假第一次做感觉很困难,现在看就清晰了很多 #include<cstdio> #include<cstr ...
- swift学习——枚举
swift枚举 1. 枚举基本语法 enum Method { case Add case Sub case Mul case Div } 也可以使用一种更简单的写法 enum Method1{ ca ...
- Vue的 $parent,并不能准确找到上一层的控件,所以如果需要,需要填坑这个 bug,递归寻找下上级
Vue的 $parent,并不能准确找到上一层的控件,所以如果需要,需要填坑这个 bug,递归寻找下上级 // Find components upward function findComponen ...
- axios token header response request http拦截器 axios实现登录、拦截、登出
axios token header response request http拦截器 axios实现登录.拦截.登出 一个项目学会前端实现登录拦截 https://github.com/superm ...
- && (and)、||(or) 条件语句
当前面条件满足时,就执行后面的代码 //条件为真时,就执行其中的语句 if($a>0){ $b='This is test'; } //上面的写法太麻烦,可以这样简写 $a>0 & ...
- Java之字符,字符串替换
/** 4. 字符串的替换操作 1. String replace(char oldChar,char newChar) //将新字符替换旧字符 3. String replaceFirst(Stri ...
- python-水仙花数
>>> for a in range(1,10):... for b in range(0,10):... for c in range(0,10):... x=100*a+10*b ...
- 获得Dictionary所有key和value值
Dictionary<string, string> dc = new Dictionary<string, string>(); dc.Add("code" ...
- html5新增的定时器requestAnimationFrame
在requestAnimationFrame出现之前,我们一般都用setTimeout和setInterval,那么html5为什么新增一个requestAnimationFrame,他的出现是为了解 ...