NCPC 2016 Game Rank(纯模拟)
来源:互联网 发布:u盘装linux系统 编辑:程序博客网 时间:2024/05/21 03:59
G: Game Rank
时间限制: 1 Sec 内存限制: 64 MB
题目描述
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, 1 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 1 or 2 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 1 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-21: 2 stars
• Rank 20-16: 3 stars
• Rank 15-11: 4 stars
• Rank 10-1: 5 stars
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?
输入
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 1 and 10 000 characters (inclusive).
输出
Output a single line containing a rank after having played the given sequence of games; either an integer between 1 and 25 or “ Legend ”.
样例输入
WW
样例输出
25
题意:*炉石传说,真尼玛好玩。
1.玩家赢得比赛,他会获得一个星 在6 - 25级之间连续三连胜以上,他可以获得一个额外的星星,当前的星超过了当前等级的限制的时候就会上升一个等级
2.输了一场比赛,他就失去了一颗星,如果玩家在当前排名是零星,失去一颗星后,那么他将失去一个等级,然后得到在下面的排名中满星减去一个的数量的星。
3.二十级0星的时候输不会掉星星。
4.如果达到了Legend等级的时候就再输都不会掉级了。
5.这题是Special Judge。有一个比较坑的点就是那个连胜的判断是在该盘加星之前的(虽然我也不知道为什么),先加和后加其实没有区别,但是会wa就很绝望,也算是给自己提个醒把,老老实实按照题意。
#include<bits/stdc++.h>using namespace std;char s[11000];int main (){ scanf("%s",s); int len = strlen(s); int star = 0; int still_win = 0; int rank = 25; for (int i = 0; i < len; i++){ if (rank == 0) { break; } if (s[i] == 'W'){ still_win ++; if (still_win >= 3 && rank > 5) star++; star++; if (rank<=25 && rank>=21 && star > 2) { rank--; star-=2; } if (rank>=16 && rank<=20 && star > 3){ rank--; star-=3; } if (rank>=11 && rank<=15 && star > 4){ rank--; star-=4; } if (rank>=1 && rank<=10 && star > 5){ rank--; star-=5; } } else { still_win = 0; if (rank>=21) continue; star --; // if (star < 0){ if (rank == 20) { star = 0; } if (rank>=15 && rank<=19){ rank++; star = 2; } if (rank>=10 && rank<15){ rank++; star = 3; } if (rank>=1 && rank<=9){ rank++; star = 4; } } } } if (!rank) printf("Legend\n"); else printf("%d\n",rank); return 0;}
- NCPC 2016 Game Rank(纯模拟)
- 2016 NCPC Game Rank(模拟)
- 【模拟】NCPC 2014 D Dice Game
- NCPC 2016 Fleecing the Raffle(推导)
- Problem G. Game Rank---Urozero Autumn Training Camp 2016-Day 1||简单模拟
- 【模拟】NCPC 2014 E ceremony
- 【模拟】NCPC 2014 K Train passengers
- 约瑟夫环(纯模拟)
- NCPC 2016 A Artwork(并查集)
- Game(bc模拟题)
- HDU 5523 Game(模拟)
- ZJU1024-Calendar Game(模拟)
- HDU 5097 Page Rank(模拟,矩阵运算)
- [ACM] HDU 5131 Song Jiang's rank list (模拟)
- HDOJ 题目5097 Page Rank(矩阵运算,模拟)
- hdu 5131 Song Jiang's rank list(模拟)
- 纯js(jq)模拟alert弹窗
- rank()
- JAVAWEB学习01 ---HTML
- 关于Servlet路径跳转问题
- db2 connector加载数据时报SQL1476N
- OpenCV颜色空间转换函数:cv::cvtColor介绍
- python 性能提升之 并行map
- NCPC 2016 Game Rank(纯模拟)
- 人脸检测长文(下)
- 学习JAVA的理解2
- 操作系统 中断异常系统调用
- HDU 2191-悼念512汶川大地震遇难同胞——珍惜现在,感恩生活
- linux入门-ansible安装,pip安装
- spring in action笔记(二)——依赖注入
- 使用Docker搭建ELK日志系统
- 转载:Java并发编程:volatile关键字解析