UVa - 12450 - SpaceRecon Tournament
先上题目:
Problem G: SpaceRecon Tournament
SpaceRecon, the hottest game of 2011, is a real-time strategy thriller where players control your armies to destroy their opponent. Players may choose from one of the three available races -- Xurks (biological), Protoast (technological), and Earthians (humanoids) -- to build their respective armies by collecting resources from the land and spending them on army units, upgrades, and infrastructure. The player who destroys or outlasts their opponent is victorious.

The game has an intricate single-player story mode where players recreate scenes of the survival of Earthian Commander John Rainard's travels through the Xurkling planet, and also the charades of once-Earthian-now-Xurkling Queen Stephanie Karpenter. After completing the 15 hours of single player gameplay, most users try their hand at multiplayer head-to-head battles online using Actionweb, the number one SpaceRecon game matching hub.
Actionweb hosts tournaments of 2^M players and publishes the results of each tournament by listing each player handle and the number of match victories in the tournament. Tournaments are series of head-to-head matches between two players, the winner of the round advancing to the next round. The first R rounds are best of three (i.e., win two matches to win the round, any unnecessary games are not played), the remaining rounds are best of five (i.e., win three matches to win the round, any unnecessary games are not played). Each tournament has a different value of R, but is not published.
Input Format
The first line is an integer N (1 <= N <= 100), the number of test cases, which follow. Each test case begins with a line containing an integer M (1 <= M <= 10). The following 2^M lines are of format "player_handle number_of_match_victories". Player handles are alphanumeric and between 1 and 16 characters long.
You may assume that the data provided describes a valid tournament.
Output Format
Print the player handles sorted in descending order of which round they survived to. For players who survived the same number of rounds, sort them lexicographically by player handle.
Sample Input
1
2
John 1
Jake 5
Joe 4
Jane 0
Sample Output
Jake
Joe
Jane
John 题意:给你2^m个选手的比赛胜利情况,这2^m个选手进行挑战赛,问最终按照进行比赛的round数来排序输出,如果round数相同的就按照字典序输出。其中一个round有可能三局两胜有可能五局三胜。(前R场三局两胜,剩下的五局三胜)
说实话第一次读题意的时候完全看不懂,看了好几次才看懂,比赛的时候觉得应该枚举R,因为m最大只有10,换而言之挑战赛构成的树最深只有10层,所以直接枚举R,如果有合法的状态就输出。结果不够时间敲,赛后听题解说的是R其实是确定的不需要枚举。
刚才用自己的想法实现了一下,WA了主要还是没有确定R。其实分析一下可以发现,对于所有的人,明显胜利场数最多的人必定是冠军(树根)他的round数绝对是最多的,然后就是胜利场数稍微少一点的绝对是比冠军少一round,然后继续这样推下去就可以发现如果我们先按照胜利场数推下去的话我们可以发现,场数多的绝对是round数多,每一次我们可以确定2^i个人排在前面,最后就能将2^m的人都排好。 上代码:
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <utility>
#include <vector>
#include <queue>
#include <algorithm>
#define MAX 102
using namespace std; typedef pair<int,string> pii;
pii p;
vector<pii> u;
int m; bool cmp0(pii x,pii y){
return x.first==y.first ? x.second<y.second : x.first>y.first;
} bool cmp1(pii x,pii y){
return x.second<y.second;
} int main()
{
int t,n;
//freopen("data.txt","r",stdin);
ios::sync_with_stdio(false);
cin>>t;
while(t--){
cin>>m;
n=<<m;
u.clear();
for(int i=;i<n;i++){
cin>>p.second>>p.first;
u.push_back(p);
}
sort(u.begin(),u.end(),cmp0);
int bound=;
for(vector<pii>::iterator it=u.begin()+;it!=u.end();bound<<=){
sort(it,it+bound,cmp1);
it=it+bound;
}
for(vector<pii>::iterator it=u.begin();it!=u.end();it++){
cout<<(*it).second<<endl;
}
}
return ;
}
/*12450*/
UVa - 12450 - SpaceRecon Tournament的更多相关文章
- UVA 10194 (13.08.05)
:W Problem A: Football (aka Soccer) The Problem Football the most popular sport in the world (ameri ...
- Codeforces CF#628 Education 8 A. Tennis Tournament
A. Tennis Tournament time limit per test 1 second memory limit per test 256 megabytes input standard ...
- uva 1354 Mobile Computing ——yhx
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAABGcAAANuCAYAAAC7f2QuAAAgAElEQVR4nOy9XUhjWbo3vu72RRgkF5
- UVA 10564 Paths through the Hourglass[DP 打印]
UVA - 10564 Paths through the Hourglass 题意: 要求从第一层走到最下面一层,只能往左下或右下走 问有多少条路径之和刚好等于S? 如果有的话,输出字典序最小的路径 ...
- UVA 11404 Palindromic Subsequence[DP LCS 打印]
UVA - 11404 Palindromic Subsequence 题意:一个字符串,删去0个或多个字符,输出字典序最小且最长的回文字符串 不要求路径区间DP都可以做 然而要字典序最小 倒过来求L ...
- UVA&&POJ离散概率与数学期望入门练习[4]
POJ3869 Headshot 题意:给出左轮手枪的子弹序列,打了一枪没子弹,要使下一枪也没子弹概率最大应该rotate还是shoot 条件概率,|00|/(|00|+|01|)和|0|/n谁大的问 ...
- UVA计数方法练习[3]
UVA - 11538 Chess Queen 题意:n*m放置两个互相攻击的后的方案数 分开讨论行 列 两条对角线 一个求和式 可以化简后计算 // // main.cpp // uva11538 ...
- UVA数学入门训练Round1[6]
UVA - 11388 GCD LCM 题意:输入g和l,找到a和b,gcd(a,b)=g,lacm(a,b)=l,a<b且a最小 g不能整除l时无解,否则一定g,l最小 #include &l ...
- UVA - 1625 Color Length[序列DP 代价计算技巧]
UVA - 1625 Color Length 白书 很明显f[i][j]表示第一个取到i第二个取到j的代价 问题在于代价的计算,并不知道每种颜色的开始和结束 和模拟赛那道环形DP很想,计算这 ...
随机推荐
- P2622 关灯问题II(状压bfs)
P2622 关灯问题II 题目描述 现有n盏灯,以及m个按钮.每个按钮可以同时控制这n盏灯——按下了第i个按钮,对于所有的灯都有一个效果.按下i按钮对于第j盏灯,是下面3中效果之一:如果a[i][j] ...
- golang——log包学习
log包实现了简单的日志服务. 1.func New(out io.Writer, prefix string, flag int) *Logger New创建一个Logger. 参数out设置日志信 ...
- deepin 安装 idea
1.su root 2.sudo apt install idea 3.sudo vi /etc/hosts 最后一行添加 0.0.0.0 account.jetbrains.com 4.注册码 N7 ...
- [转]C语言文件操作函数大全(超详细)
fopen(打开文件)相关函数 open,fclose表头文件 #include<stdio.h>定义函数 FILE * fopen(const char * path,const cha ...
- JS数组、outerHtml、className
//对象转换为数组function obj(){for(var i=0;i<arguments.length;i++){ this[i]=arguments[i]; }} var o2=new ...
- 373 Find K Pairs with Smallest Sums 查找和最小的K对数字
给定两个以升序排列的整形数组 nums1 和 nums2, 以及一个整数 k.定义一对值 (u,v),其中第一个元素来自 nums1,第二个元素来自 nums2.找到和最小的 k 对数字 (u1,v1 ...
- node-rsa加密,java解密调试
用NODE RSA JS 加密解密正常,用JAVA RSAUtils工具类加密解密正常.但是用node加密玩的java解密不了.原因:node默认的是 DEFAULT_ENCRYPTION_SCHEM ...
- [ Luogu 4917 ] 天守阁的地板
\(\\\) \(Description\) 定义二元函数\(F(x,y)\)表示,用 \(x\times y\) 的矩形不可旋转的铺成一个任意边长的正方形,所需要的最少的矩形个数. 现在\(T\)组 ...
- CSS 潜藏着的BFC
在写样式时,往往是添加了一个样式,又或者是修改了某个属性,就达到了我们的预期. 而BFC就潜藏在其中,当你修改样式时,一不小心就能触发它而毫无察觉,因此没有意识到BFC的神奇之处. 什么是BFC(Bl ...
- 【Linux】Tomcat安装及端口配置
安装环境 :Linux(CentOS 64位) 安装软件 : apache-tomcat-9.0.20.tar.gz(下载地址http://tomcat.apache.org/) 一:JDK安装配置 ...