Kattis - Game Rank
Game Rank
The gaming company Sandstorm is developing an online two player game. You have been asked to implement the ranking system. All players have a rank determining their playing strength which gets updated after every game played. There are 2525 regular ranks, and an extra rank, “Legend”, above that. The ranks are numbered in decreasing order, 2525 being the lowest rank, 11 the second highest rank, and Legend the highest rank.
Each rank has a certain number of “stars” that one needs to gain before advancing to the next rank. If a player wins a game, she gains a star. If before the game the player was on rank 66-2525, and this was the third or more consecutive win, she gains an additional bonus star for that win. When she has all the stars for her rank (see list below) and gains another star, she will instead gain one rank and have one star on the new rank.
For instance, if before a winning game the player had all the stars on her current rank, she will after the game have gained one rank and have 11 or 22 stars (depending on whether she got a bonus star) on the new rank. If on the other hand she had all stars except one on a rank, and won a game that also gave her a bonus star, she would gain one rank and have 11 star on the new rank.
If a player on rank 11-2020 loses a game, she loses a star. If a player has zero stars on a rank and loses a star, she will lose a rank and have all stars minus one on the rank below. However, one can never drop below rank 2020(losing a game at rank 2020 with no stars will have no effect).
If a player reaches the Legend rank, she will stay legend no matter how many losses she incurs afterwards.
The number of stars on each rank are as follows:
Rank 2525-2121: 22 stars
Rank 2020-1616: 33 stars
Rank 1515-1111: 44 stars
Rank 1010-11: 55 stars
A player starts at rank 2525 with no stars. Given the match history of a player, what is her rank at the end of the sequence of matches?
Input
The input consists of a single line describing the sequence of matches. Each character corresponds to one game; ‘W’ represents a win and ‘L’ a loss. The length of the line is between 11 and 1000010000 characters (inclusive).
Output
Output a single line containing a rank after having played the given sequence of games; either an integer between 11 and 2525 or “Legend”.
Sample Input 1 | Sample Output 1 |
---|---|
WW |
25 |
Sample Input 2 | Sample Output 2 |
---|---|
WWW |
24 |
Sample Input 3 | Sample Output 3 |
---|---|
WWWW |
23 |
Sample Input 4 | Sample Output 4 |
---|---|
WLWLWLWL |
24 |
Sample Input 5 | Sample Output 5 |
---|---|
WWWWWWWWWLLWW |
19 |
Sample Input 6 | Sample Output 6 |
---|---|
WWWWWWWWWLWWL |
18 |
题意
25级升24级,要两颗星,但是不是两颗星满了升24,是3颗星才升级变成24级一星。然后24到23到……一直到20都是两颗星,然后3颗星 4颗星 5颗星,然后你20级以下是不掉级的,输了也不掉,如果你是20级0星不会掉星,但是20级一颗星就会掉,你掉级条件是,当前星数为0而且输了,那就掉级了,然后,他还有一个设定,如果在5级以下连胜三局或者以上,一局奖励两颗星,然后,一级是顶级,超过了一级就直接输出LEGEND,接下来那个人输成什么样都是LEGEND,其实就是炉石传说的规则
代码
#include<bits/stdc++.h>
using namespace std;
int k[] = {, , , , , , , , , , , , , , , , , , , , , , , , , };
char aa[];
int main() {
int n;
while (~scanf("%s", aa)) {
n = strlen(aa);
int ans = , b = ;
for (int i = ; i < n; i++) {
if (aa[i] == 'W') {
b++;
if (i > && aa[i - ] == 'W' && aa[i - ] == 'W' && ans >= )b++;
if (b > k[ans]) {
b -= k[ans]; ans--;
}
} else {
if (ans > || ans == && b == ) {
continue;
}
b--;
if (b < ) {
ans++; b = k[ans] - ;
}
}
if (ans == )break;
}
if (ans) {
printf("%d\n", ans);
} else {
puts("Legend");
}
}
return ;
}
Kattis - Game Rank的更多相关文章
- UVA, 10336 Rank the Languages
难点在于:递归函数和输出: #include <iostream> #include <vector> #include <algorithm> #include ...
- [LeetCode] Rank Scores 分数排行
Write a SQL query to rank scores. If there is a tie between two scores, both should have the same ra ...
- rank()函数的使用
排序: ---rank()over(order by 列名 排序)的结果是不连续的,如果有4个人,其中有3个是并列第1名,那么最后的排序结果结果如:1 1 1 4select scoreid, stu ...
- [转]oracle分析函数Rank, Dense_rank, row_number
oracle分析函数Rank, Dense_rank, row_number 分析函数2(Rank, Dense_rank, row_number) 目录 ==================== ...
- 分区函数Partition By的与row_number()的用法以及与排序rank()的用法详解(获取分组(分区)中前几条记录)
partition by关键字是分析性函数的一部分,它和聚合函数不同的地方在于它能返回一个分组中的多条记录,而聚合函数一般只有一条反映统计值的记录,partition by用于给结果集分组,如果没有指 ...
- Learning to rank 介绍
PS:文章主要转载自CSDN大神hguisu的文章"机器学习排序": http://blog.csdn.net/hguisu/article/details/79 ...
- R语言排序:sort(),rank(),order()示例
> x<-c(97,93,85,74,32,100,99,67) > sort(x) [1] 32 67 74 85 93 97 99 100 > order(x) [1] 5 ...
- [Machine Learning] Learning to rank算法简介
声明:以下内容根据潘的博客和crackcell's dustbin进行整理,尊重原著,向两位作者致谢! 1 现有的排序模型 排序(Ranking)一直是信息检索的核心研究问题,有大量的成熟的方法,主要 ...
- sqlserver 中row_number,rank,dense_rank,ntile排名函数的用法
1.row_number() 就是行号 2.rank:类似于row_number,不同之处在于,它会对order by 的字段进行处理,如果这个字段值相同,那么,行号保持不变 3.dense_rank ...
随机推荐
- 【ABCD组】Scrum meeting 5
前言 第5次会议在6月17日由组长在教9 405召开. 主要对下一步的工作进行说明安排,时长90min. 主要内容 分配下阶段任务,争取在这阶段完成软件的设计阶段 任务分配 姓名 当前阶段任务 贡献时 ...
- JS代码引用位置问题-转
看到很多JS代码全部放在head中的情况,其实这是个细节问题.转载一个知乎用户于江水的答案: 作者:于江水链接:https://www.zhihu.com/question/34147508/answ ...
- 0926mysql中MRR的用法
转自 http://blog.itpub.net/22664653/viewspace-1673682 [MySQL]MySQL5.6新特性之Multi-Range Read 2015-05-27 ...
- 0619数据库_MySQL_由浅入深理解索引的实现
转自http://blog.csdn.net/u010003835/article/details/51563348 这篇文章是介绍MySQL数据库中的索引是如何根据需求一步步演变最终成为B+树结构的 ...
- JAVA集合泛型,类型擦除,类型通配符上限之类的知识点
感觉定义要比PYTHON严谨很多,一切源于静态语言的特点吧.. 于是语法上就复杂很多,值不值得呢? 参考测试URL: http://www.cnblogs.com/lwbqqyumidi/p/3837 ...
- BA-WG-冷源
冷源群控系统最好由冷源厂家来做的理由 1.冷机厂家对空调的参数十分的清楚,明确的知道冷机的负荷曲线,可以优化冷机加减载的最合理时间达到最佳的节能效果 2.独立的CSM硬件模块,内置不同冷机的型号特性, ...
- Android-黑科技-微信抢红包必备软件
黑科技微信抢红包 介绍: 本节类容和技术无太大关系.主要是个人认为比較好玩,年关将至,对于新起之秀微信红包.绝对是过春节首选.看到就是赚到,速速围观下载.眼下仅 ...
- js限制checkbox选中个数
今天在做项目时,碰到一个问题,我须要展示多个checkbox复选框,而仅仅能同意最多选6个.调试了老半天.最终出来了,代码例如以下: <SCRIPT LANGUAGE="JavaScr ...
- luogu2606 排列计数
题目大意 求满足下列条件的排列$P$的数量:$\forall P_i, P_i>P_{\lfloor \frac{i}{2}\rfloor}$. 思路 从下标入手 反过来想,也就是对$\fora ...
- sql server中的悲观锁和乐观锁
https://www.cnblogs.com/chenwolong/p/Lock.html https://www.cnblogs.com/dengshaojun/p/3955826.html ht ...