先上题目:

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. 1
  2. 2
  3. John 1
  4. Jake 5
  5. Joe 4
  6. Jane 0

Sample Output

  1. Jake
  2. Joe
  3. Jane
  4. John
  5.  
  6.   题意:给你2^m个选手的比赛胜利情况,这2^m个选手进行挑战赛,问最终按照进行比赛的round数来排序输出,如果round数相同的就按照字典序输出。其中一个round有可能三局两胜有可能五局三胜。(前R场三局两胜,剩下的五局三胜)
      说实话第一次读题意的时候完全看不懂,看了好几次才看懂,比赛的时候觉得应该枚举R,因为m最大只有10,换而言之挑战赛构成的树最深只有10层,所以直接枚举R,如果有合法的状态就输出。结果不够时间敲,赛后听题解说的是R其实是确定的不需要枚举。
      刚才用自己的想法实现了一下,WA了主要还是没有确定R。其实分析一下可以发现,对于所有的人,明显胜利场数最多的人必定是冠军(树根)他的round数绝对是最多的,然后就是胜利场数稍微少一点的绝对是比冠军少一round,然后继续这样推下去就可以发现如果我们先按照胜利场数推下去的话我们可以发现,场数多的绝对是round数多,每一次我们可以确定2^i个人排在前面,最后就能将2^m的人都排好。
  7.  
  8. 上代码:
  1. #include <iostream>
  2. #include <cstdio>
  3. #include <string>
  4. #include <cstring>
  5. #include <utility>
  6. #include <vector>
  7. #include <queue>
  8. #include <algorithm>
  9. #define MAX 102
  10. using namespace std;
  11.  
  12. typedef pair<int,string> pii;
  13. pii p;
  14. vector<pii> u;
  15. int m;
  16.  
  17. bool cmp0(pii x,pii y){
  18. return x.first==y.first ? x.second<y.second : x.first>y.first;
  19. }
  20.  
  21. bool cmp1(pii x,pii y){
  22. return x.second<y.second;
  23. }
  24.  
  25. int main()
  26. {
  27. int t,n;
  28. //freopen("data.txt","r",stdin);
  29. ios::sync_with_stdio(false);
  30. cin>>t;
  31. while(t--){
  32. cin>>m;
  33. n=<<m;
  34. u.clear();
  35. for(int i=;i<n;i++){
  36. cin>>p.second>>p.first;
  37. u.push_back(p);
  38. }
  39. sort(u.begin(),u.end(),cmp0);
  40. int bound=;
  41. for(vector<pii>::iterator it=u.begin()+;it!=u.end();bound<<=){
  42. sort(it,it+bound,cmp1);
  43. it=it+bound;
  44. }
  45. for(vector<pii>::iterator it=u.begin();it!=u.end();it++){
  46. cout<<(*it).second<<endl;
  47. }
  48. }
  49. return ;
  50. }

/*12450*/

UVa - 12450 - SpaceRecon Tournament的更多相关文章

  1. UVA 10194 (13.08.05)

    :W Problem A: Football (aka Soccer)  The Problem Football the most popular sport in the world (ameri ...

  2. 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 ...

  3. uva 1354 Mobile Computing ——yhx

    aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAABGcAAANuCAYAAAC7f2QuAAAgAElEQVR4nOy9XUhjWbo3vu72RRgkF5

  4. UVA 10564 Paths through the Hourglass[DP 打印]

    UVA - 10564 Paths through the Hourglass 题意: 要求从第一层走到最下面一层,只能往左下或右下走 问有多少条路径之和刚好等于S? 如果有的话,输出字典序最小的路径 ...

  5. UVA 11404 Palindromic Subsequence[DP LCS 打印]

    UVA - 11404 Palindromic Subsequence 题意:一个字符串,删去0个或多个字符,输出字典序最小且最长的回文字符串 不要求路径区间DP都可以做 然而要字典序最小 倒过来求L ...

  6. UVA&&POJ离散概率与数学期望入门练习[4]

    POJ3869 Headshot 题意:给出左轮手枪的子弹序列,打了一枪没子弹,要使下一枪也没子弹概率最大应该rotate还是shoot 条件概率,|00|/(|00|+|01|)和|0|/n谁大的问 ...

  7. UVA计数方法练习[3]

    UVA - 11538 Chess Queen 题意:n*m放置两个互相攻击的后的方案数 分开讨论行 列 两条对角线 一个求和式 可以化简后计算 // // main.cpp // uva11538 ...

  8. 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 ...

  9. UVA - 1625 Color Length[序列DP 代价计算技巧]

    UVA - 1625 Color Length   白书 很明显f[i][j]表示第一个取到i第二个取到j的代价 问题在于代价的计算,并不知道每种颜色的开始和结束   和模拟赛那道环形DP很想,计算这 ...

随机推荐

  1. vs2017 + miniUI + dapper 添加、修改、删除、查询操作

    A.数据库表引用先前建立的company 公司信息表. B.建立文件: views > Home > Company.cshtml(新建文件) ,代码如下(直接复制即可) @{ Layou ...

  2. loadrunner11 安装破解,汉化包

    说说自己的心痛史,好不容易安装了loadrunner 11 居然浏览器不支持,我的系统是win8.1,ie浏览器最低支持ie11,我还能说啥子...其他浏览器试过了依旧是不可以!!所以我安装了一个虚拟 ...

  3. 数学 FZU 2074 Number of methods

    题目传送门 /* 数学:假设取了第i个,有C(n-1)(i-1)种取法 则ans = sum (C(n-1)(i-1)) (1<i<=n) 即2^(n-1) */ #include < ...

  4. G - And Then There Was One (约瑟夫环变形)

    Description Let’s play a stone removing game. Initially, n stones are arranged on a circle and numbe ...

  5. python程序展现图片

    突然想写一个python程序能够显示图片的 ,展示文字的已经实现了 现在就搞一搞这个吧 相信也是很简单 首先是放一张图片在e盘下面 等会程序打包的时候将会用到 就决定是你啦 皮卡丘: 然后就写代码吧:

  6. FCC 基础JavaScript 练习7

    1. Math.random()用来生成一个在0(包括0)到1(不包括1)之间的随机小数,因此Math.random()可能返回0但绝不会返回1. 提示随后的函数都会在return执行前调用,所以我们 ...

  7. Linux学习日记之Deepin下查看crontab运行日志

    Deepin使用 journalctl 替代了 syslog 来处理系统日志 故查看crontab运行日志应使用 journalctl -f /usr/sbin/cron

  8. RabbitMQ调用

    添加 gradle依赖complie("com.rabbitmq:amqp-client:5.0.0") Hello, World Working Queues Publish/S ...

  9. 3星|《未来公司》:Uber简史

    未来公司(卡兰尼克和他的Uber帝国)(精) 从Uber创始人卡兰尼克的角度讲的Uber简史,截止到2017年.书中有不少Uber的负面新闻,比国内的同类书要好. 基本是流水账.想了解这家公司的历史, ...

  10. python爬虫(房天下)

    房天下 import requests res = requests.get('http://esf.sz.fang.com/') #res.text from bs4 import Beautifu ...