计蒜客————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?

计蒜客————Game Rank_第1张图片

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
#include
#include
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


你可能感兴趣的:(计蒜客)