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 ...
随机推荐
- Implicit Animations 默认动画 读书笔记
Implicit Animations 默认动画 读书笔记 Do what I mean, not what I say. Edna Krabappel, The Simpsons Part I ...
- ubuntu 下service php5-fpm restart 报错 stop: Unknown instance: 解决
问题描述: 在安装完扩展后,重启php-fpm,发现一直停止报错 stop: Unknown instance: 通过查看进程,也查询不到该主进程 解决办法: 干掉现在正在执行的进程 pkill ph ...
- laravel如何查找门脸及注入类方法
门脸模式 通过 config/app.php 查看别名对应类名 Illuminate\Support\Facades\Log ,查看 LoggerInterface 类文件,得:命名空间+接口名 Ps ...
- vue下axios和fetch跨域请求
1.在config的index.js下面进行常用跨域配置代码:proxyTable: { '/apis': { //使用"/api"来代替"http://xxxx.cn& ...
- 洛谷 P1918 保龄球
题目描述 DL 算缘分算得很烦闷,所以常常到体育馆去打保龄球解闷.因为他保龄球已经打了几十年了,所以技术上不成问题,于是他就想玩点新花招. DL 的视力真的很不错,竟然能够数清楚在他前方十米左右每个位 ...
- Vue构建命令
node -v npm -v vue -V npm install vue (这个命令不行) 提示信息:+ vue@2.6.10 updated 1 package and audited 1 pac ...
- QT+ 使用标准对话框+关于对话框+问题对话框+文件对话框
#include "mainwindow.h" #include <QMenuBar> #include <QMenu> #include <QAct ...
- delphi并行压缩
real case test MM parallel 4x scalable (i7 6700)(on the newer processors will be linear) I did a sma ...
- Eclipse的PyDev插件安装及解决安装后找不到的问题
一.环境 windows 7 64bit eclipse 4.5.2 pydev jdk7u55 二.安装步骤 1. 安装JDK eclipse依赖于Java环境,所以需要安装Java运行环境JRE. ...
- spring mvc poi excel
Util类 package com.common.util; public class ExportUtil { private XSSFWorkbook wb = null; private XSS ...