Codeforces 659B Qualifying Contest【模拟,读题】
来源:互联网 发布:网络机顶盒怎么安装图 编辑:程序博客网 时间:2024/05/29 17:05
写这道题题解的目的就是纪念一下半个小时才读懂题。。。英文一多读一读就溜号。。。
读题时还时要静下心来。。。
题目链接:
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;}
0 0
- Codeforces 659B Qualifying Contest【模拟,读题】
- Codeforces 659B Qualifying Contest 【模拟】
- CodeForces 659B Qualifying Contest
- CodeForces-659B-Qualifying Contest
- CodeForces - 659B Qualifying Contest (模拟)水
- CodeForces 659 B. Qualifying Contest(结构体排序的问题)
- B. Qualifying Contest 结构体模拟
- B - Qualifying Contest
- CodeForces 659B Qualifying Contest(选2个人参加比赛)
- Codeforces Round #346 (Div. 2)-B. Qualifying Contest(排序)
- Codeforces Round #346 (Div. 2)--B. Qualifying Contest
- Codeforces Round #346 (Div. 2) B. Qualifying Contest
- Codeforces Round #346 (Div. 2) - B Qualifying Contest
- Codeforces Round #346 (Div. 2) B. Qualifying Contest
- Codeforces Round #346 (Div. 2) B - Qualifying Contest 优先队列
- B. Valera and Contest----模拟
- codeforces contest 785 b题
- codeforces contest 779 B题
- MFC-利用内存映射文件来读写文件
- Masonry - 自动布局
- BeestCoder #76
- bzoj 4444: [Scoi2015]国旗计划 递推
- PHPCMS 配置文件
- Codeforces 659B Qualifying Contest【模拟,读题】
- Android测试框架之Robolectric
- 网络开发:在Socket中发送大文件
- Linux 批量修改服务器密码
- 四元数(Quaternion)和旋转
- 计算机网络知识点总结
- 设计模式(六)策略模式Strategy
- 用Kibana和logstash快速搭建实时日志查询、收集与分析系统
- CodeForces 18E Flag 2 (dp)