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. 使用requirejs模块化开发多页面一个入口js的使用方式

    描述 知道requirejs的都知道,每一个页面需要进行模块化开发都得有一个入口js文件进行模块配置.但是现在就有一个很尴尬的问题,如果页面很多的话,那么这个data-main对应的入口文件就会很多. ...

  2. CodeForces - 9B - Running Student

    先上题目: B. Running Student time limit per test 1 second memory limit per test 64 megabytes   And again ...

  3. 0614MySQL的InnoDB索引原理详解

    转自http://www.cnblogs.com/shijingxiang/articles/4743324.html MySQL的InnoDB索引原理详解 http://www.admin10000 ...

  4. [bzoj1708][Usaco2007 Oct]Money奶牛的硬币_动态规划_背包dp

    Money奶牛的硬币 bzoj-1708 Usaco-2007 Oct 题目大意:在创立了她们自己的政权之后,奶牛们决定推广新的货币系统.在强烈的叛逆心理的驱使下,她们准备使用奇怪的面值.在传统的货币 ...

  5. 恩布企业IM PC端,服务端公布 1.16 版本号

    恩布企业IM PC端,服务端公布1.16版本号,开源企业IM.免费企业即时通讯软件:主要版本号更新内容: 恩布服务端核心程序,添加进程守护保护机制,确保系统7*24持续稳定服务: 服务端添加内存数据库 ...

  6. ListViewItem中的图片不能动态改变的解决方法

    近期遇到了一个问题,就是我的listviewitem中有个图片,点击的时候须要变成还有一种图片.结果在getView()中设置了响应.可是能够运行.就是不起作用.在网上查了非常多资料也没有解决.最后发 ...

  7. 支付宝钱包手势password破解实战(root过的手机可直接绕过手势password)

    /* 本文章由 莫灰灰 编写,转载请注明出处. 作者:莫灰灰    邮箱: minzhenfei@163.com */ 背景 随着移动互联网的普及以及手机屏幕越做越大等特点,在移动设备上购物.消费已是 ...

  8. structs实现三种action的方法

    第一种:一般类,带有public String execute()方法. 另外一种:继承LoginActionInterface implements Action接口的类. 第三种:继承LoginA ...

  9. Java异常的处理机制(二)

    1.throw的作用 class Usre { private int age; public void setAge (int age) { if(age < 0) { RuntimeExce ...

  10. MySQL Study之--MySQL体系结构深入解析

    MySQL Study之--MySQL体系结构深入解析 MySQL体系架构 由连接池组件.管理服务和⼯工具组件.sql接口组件.查询分析器组件.优化器组件.缓冲组件.插件式存储引擎.物理⽂文件组成.m ...