Game Rank

Picture by Gonkasth on DeviantArt, cc by-nd

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的更多相关文章

  1. UVA, 10336 Rank the Languages

    难点在于:递归函数和输出: #include <iostream> #include <vector> #include <algorithm> #include ...

  2. [LeetCode] Rank Scores 分数排行

    Write a SQL query to rank scores. If there is a tie between two scores, both should have the same ra ...

  3. rank()函数的使用

    排序: ---rank()over(order by 列名 排序)的结果是不连续的,如果有4个人,其中有3个是并列第1名,那么最后的排序结果结果如:1 1 1 4select scoreid, stu ...

  4. [转]oracle分析函数Rank, Dense_rank, row_number

    oracle分析函数Rank, Dense_rank, row_number 分析函数2(Rank, Dense_rank, row_number)   目录 ==================== ...

  5. 分区函数Partition By的与row_number()的用法以及与排序rank()的用法详解(获取分组(分区)中前几条记录)

    partition by关键字是分析性函数的一部分,它和聚合函数不同的地方在于它能返回一个分组中的多条记录,而聚合函数一般只有一条反映统计值的记录,partition by用于给结果集分组,如果没有指 ...

  6. Learning to rank 介绍

    PS:文章主要转载自CSDN大神hguisu的文章"机器学习排序":          http://blog.csdn.net/hguisu/article/details/79 ...

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

  8. [Machine Learning] Learning to rank算法简介

    声明:以下内容根据潘的博客和crackcell's dustbin进行整理,尊重原著,向两位作者致谢! 1 现有的排序模型 排序(Ranking)一直是信息检索的核心研究问题,有大量的成熟的方法,主要 ...

  9. sqlserver 中row_number,rank,dense_rank,ntile排名函数的用法

    1.row_number() 就是行号 2.rank:类似于row_number,不同之处在于,它会对order by 的字段进行处理,如果这个字段值相同,那么,行号保持不变 3.dense_rank ...

随机推荐

  1. js中获取数组中的最大值最小值

    var a=[1,2,3,5]; alert(Math.max.apply(null, a));//最大值 alert(Math.min.apply(null, a));//最小值 多维数组可以这么修 ...

  2. 07.网络编程-4.HTTP

    HTTP是一种无状态的协议,无状态是指Web浏览器和Web服务器之间不需要建立持久的连接,这意味着当一个客户端向服务器端发出请求,然后Web服务器返回响应(response),连接就被关闭了,在服务器 ...

  3. (ccf模拟)201709-2公共钥匙盒

    #include <iostream> #include<string> #include <algorithm> #include<sstream> ...

  4. git 添加到环境变量

    github 新增仓库的后的提示 …or create a new repository on the command line echo "# top" >> REA ...

  5. 修改oracle客户端的字符集

    客户端字符集环境select * from nls_instance_parameters,其来源于v$parameter, 表示客户端的字符集的设置,可能是参数文件,环境变量或者是注册表 方法有 : ...

  6. C# ArcgisEngine开发中,对一个图层进行过滤,只显示符合条件的要素

    转自原文 C# ArcgisEngine开发中,对一个图层进行过滤,只显示符合条件的要素 有时候,我们要对图层上的地物进行有选择性的显示,以此来满足实际的功能要求. 按下面介绍的方法可轻松实现图层属性 ...

  7. HDU 3002

    无向图最小割. #include <iostream> #include <cstdio> #include <cstring> using namespace s ...

  8. POJ 3281(Dining-网络流拆点)[Template:网络流dinic]

    watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvbmlrZTBnb29k/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA ...

  9. rar x 解压rar文件,提示permission denied

    问题: 解压rar文件,提示

  10. Android requires compiler compliance level 5.0 or 6.0. Found &#39;1.4&#39; instead的解决的方法

    今天在eclipse里报这个错误:   Android requires compiler compliance level 5.0 or 6.0. Found '1.4' instead. Plea ...