SGU 281.Championship
题意:
有n(n≤50000)支队伍参加了两场比赛,分别有两个排名。现在要求输出总排名,如果对任意m,在两个排名的前m个队伍都相同,那么在总排名前m个队伍就是这些队伍。其它情况按字典序排。
Solution:
简单题。
先map定位每个队伍在第一个排名中的位置。从第二个排名的第一个开始,找到最小满足条件的m,对这m个队伍按照字典序进行排序。然后继续找新的m(不包括排完序的队伍)直到所有队伍排完。
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <map>
using namespace std;
map<string, int> pos;
vector<string> Rank;
int n;
int main()
{
ios::sync_with_stdio ( );
cin >> n;
string name;
for ( int i = ; i <= n; ++i ) {
cin >> name;
pos[name] = i;
}
int r = , l = ;
for ( int i = ; i <= n; ++i ) {
cin >> name;
Rank.push_back ( name );
r = max ( r, pos[name] );
if ( i == r ) {
sort ( Rank.begin() + l, Rank.begin() + r );
l = r;
}
}
for ( int i = ; i < n; ++i ) {
cout << Rank[i] << "\n";
}
}
SGU 281.Championship的更多相关文章
- redhat6.4安装MySQL-server-5.5.28-1.linux2.6.x86_64.rpm
首先下载下面三个文件: MySQL-server-5.5.28-1.linux2.6.x86_64.rpm MySQL-client-5.5.28-1.linux2.6.x86_64.rpm MySQ ...
- SGU 495. Kids and Prizes
水概率....SGU里难得的水题.... 495. Kids and Prizes Time limit per test: 0.5 second(s)Memory limit: 262144 kil ...
- ACM: SGU 101 Domino- 欧拉回路-并查集
sgu 101 - Domino Time Limit:250MS Memory Limit:4096KB 64bit IO Format:%I64d & %I64u Desc ...
- 【SGU】495. Kids and Prizes
http://acm.sgu.ru/problem.php?contest=0&problem=495 题意:N个箱子M个人,初始N个箱子都有一个礼物,M个人依次等概率取一个箱子,如果有礼物则 ...
- SGU 455 Sequence analysis(Cycle detection,floyd判圈算法)
题目链接:http://acm.sgu.ru/problem.php?contest=0&problem=455 Due to the slow 'mod' and 'div' operati ...
- Codeforces Round #382 (Div. 2)C. Tennis Championship 动态规划
C. Tennis Championship 题目链接 http://codeforces.com/contest/735/problem/C 题面 Famous Brazil city Rio de ...
- SGU 422 Fast Typing(概率DP)
题目大意 某人在打字机上打一个字符串,给出了他打每个字符出错的概率 q[i]. 打一个字符需要单位1的时间,删除一个字符也需要单位1的时间.在任意时刻,他可以花 t 的时间检查整个打出来的字符串,并且 ...
- sgu 104 Little shop of flowers 解题报告及测试数据
104. Little shop of flowers time limit per test: 0.25 sec. memory limit per test: 4096 KB 问题: 你想要将你的 ...
- 树形DP求树的重心 --SGU 134
令一个点的属性值为:去除这个点以及与这个点相连的所有边后得到的连通分量的节点数的最大值. 则树的重心定义为:一个点,这个点的属性值在所有点中是最小的. SGU 134 即要找出所有的重心,并且找出重心 ...
随机推荐
- 【原创】Hadoop机架感知对性能调优的理解
Hadoop作为大数据处理的典型平台,在海量数据处理过程中,其主要限制因素是节点之间的数据传输速率.因为集群的带宽有限,而有限的带宽资源却承担着大量的刚性带宽需求,例如Shuffle阶段的数据传输不可 ...
- aix 扩展文件系统
今天发现公司的oracle测试 数据库不能启动,检查警告日志日志,提示归档空间不足,不能归档,于是扩展文件系统: 1.检查rootvg卷组的剩余空间[p2704u]:[/dsg/oracle11]$ ...
- Error message “Assembly must be registered in isolation” when registering Plugins in Microsoft Dynamics CRM 2011 2013 解决办法
Error message “Assembly must be registered in isolation” when registering Plugins in Microsoft Dynam ...
- mysql 中文乱码的解决办法
I would not suggest Richies answer, because you are screwing up the data inside the database. You wo ...
- autoSvn
#!/bin/bash dir="/svndata" name="puppet" user="test" passwd="t ...
- Spark源码的编译过程详细解读(各版本)
说在前面的话 重新试多几次.编译过程中会出现下载某个包的时间太久,这是由于连接网站的过程中会出现假死,按ctrl+c,重新运行编译命令. 如果出现缺少了某个文件的情况,则要先清理maven(使用命 ...
- A Tour of Go Structs
A struct is a collection of fields. (And a type declaration does what you'd expect.) package main im ...
- Jquery实现图片轮播源码
<html><head><style type="text/css">#banner {position:relative; width:478 ...
- Google正确搜索方法
以下是目前所有的Google搜索命令语法,它不同于Google的帮助文档,因为这里介绍了几个Google不推荐使用的命令语法.大多数的Google搜索命令语法有它特有的使用格式,希望大家能正确使用.我 ...
- servlet三大作用域:request,session,application
javaweb开发中Servlet三大域对象的应用(request.session.application(ServletContext)). 1. request request是表示一个请求,只要 ...