计蒜客————Game Rank

  •  26.32%
  •  1000ms
  •  65536K


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 25 regular ranks, and an extra rank,“Legend”, above that. The ranks are numbered in decreasing order, 25 being the lowest rank, 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 6-25, 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 or 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 star on the new rank.

If a player on rank 1-20 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 20 (losing a game at rank 20 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 25-21stars
  • Rank 20-16stars
  • Rank 15-11stars
  • Rank 10-1stars

A player starts at rank 25 with no stars. Given the match history of a player, what is her rank at the end of the sequence of matches?

image.png

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 and10 000 characters (inclusive). 

Output

Output a single line containing a rank after having played the given sequence of games; either an integer between and 25 or “Legend”.

样例输入1
WW
样例输出1
25
样例输入2
WLWLWLWL
样例输出2
24
样例输入3
WWWWWWWWWLWWL
样例输出3
18
炉石传说的规则.
1.在胜利时,如果处于三连胜以上的状态,予以一个奖励星,胜场予以一个星级.
  在星级超越排名所能拥有的星级时,排名等级上升.
  优先计算奖励星,奖励星只在6~25级生效.
2.负场时,失去一个星级,当前等级最少拥有0星.
   处于0星状态下负场时,排名等级降低.排名等级在21~25级或传说,不会降低.
3.对应排名及对应的最高星级,传说没有星级上限

  • Rank 25-21stars
  • Rank 20-16stars
  • Rank 15-11stars
  • Rank 10-1stars
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int main(){
    const int com[26]={95,90,85,80,75,70,65,60,55,50,45,41,37,33,29,25,22,19,16,13,10,8,6,4,2,0};
    char s[10003];
    while(~scanf("%s",s)){
        int stars=0,win=0,rank=25;
        for(int i=0;s[i];i++){
            if('W'==s[i]){
                win++;
                stars+=1+(win>=3&&stars<=70);
                if(stars>com[rank-1]&&rank) rank--;
            }
            else{
                win=0;
                if(stars>10&&stars<=95) stars--;
                if(stars>13&&stars<com[rank]) rank++;
            }
        }
        if(rank) printf("%d\n",rank);
        else printf("Legend\n");
    }
    return 0;
}


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值