Game Rank(NCPC 2016 大模拟)
题目:
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?
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 1 and 10 000 characters (inclusive).
Output:
Output a single line containing a rank after having played the given sequence of games; either an integer between 1 and 25 or “Legend”.
题意:
“炉石传说”排位模拟,条件真的多啊,列出所有的条件慢慢来就ok了。
条件:
- 每个Rank的star的个数如上。
- 如果玩家Rank处于6-25之间,那么只要连赢3场及更多场,每次加2颗star,否则赢了只能加一颗star。
- 当玩家升至Rank后就不会再掉到Rank20以下,也就是说当玩家在Rank20+0star时输了比赛,并不会掉Rank。
- 当玩家在Rank Legend的时候,输赢将不会再产生影响。
- 当玩家处于Rank x + 0star 输掉比赛,玩家的段位变为Rank (x+1)+ full-1 star,full-1也就是下一个段位最大star数减一。
注意到以上条件开工写代码:
代码:
#include <bits/stdc++.h>
#define FRE() freopen("in.txt","r",stdin)
using namespace std;
const int maxn = 1e4+;
typedef long long ll; struct Player
{
int rak;
int star;
Player()
{
rak = ;
star = ;
}
}; int judgeFullWin(int x,int star)//得到Rank上升后的star的个数
{
if(x>= && x<=)
return star-;
else if(x>= && x<=)
return star-;
else if(x>= && x<=)
return star-;
else if(x>= && x<=)
return star-;
} int judgeFullLose(int r)//返回每个Rank对应的最大的star的个数
{
if(r>= && r<=)
return ;
else if(r>= && r<=)
return ;
else if(r>= && r<=)
return ;
else if(r>= && r<=)
return ;
} int main()
{
Player p;
char str[maxn];
scanf("%s",&str);
int cw = ;
for(int i = ; str[i]; i++)
{
if(str[i]=='W' && (p.rak>= && p.rak<=))
{
if(p.rak>= && p.rak<=)//6-25获胜
{
cw++;//连胜率
if(cw>=)
{
int s = judgeFullWin(p.rak, p.star+);
if(s > )
{
p.rak--;
p.star = s;
}
else
p.star+=;
}
else
{
int s = judgeFullWin(p.rak, p.star+);
//printf("S: %d\n",s);
if(s > )
{
p.rak--;
p.star = s;
}
else
p.star++;
}
}
else if(p.rak>= && p.rak<=)
{
int s = judgeFullWin(p.rak, p.star+);
if(s > )
{
p.rak--;
p.star = s;
}
else
p.star++;
}
}
else if(str[i]=='L' && (p.rak>= && p.rak<=))
{
cw = ;//连胜率为0
if(p.rak>= && p.rak<=)
{
if((p.rak== && p.star == )||(p.rak== && p.star == ))
continue;
if(p.star==)
{
p.star = judgeFullLose(p.rak+)-;
p.rak++;
}
else
p.star--;
} }
}
if(p.rak == )
printf("Legend\n");
else
printf("%d\n",p.rak); return ;
}
/*
样例输入:
WW
WWW
WWWW
WLWLWLWL
WWWWWWWWWLLWW
WWWWWWWWWLWWL
样例输出:
25
24
23
24
19
18
*/
二刷思路清晰,代码显然要简洁多了!
#include <bits/stdc++.h>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <iomanip>
#define MAX 1000000000
#define inf 0x3f3f3f3f
#define FRE() freopen("in.txt","r",stdin) using namespace std;
typedef long long ll;
const int maxn = ;
char str[maxn]; int query(int rk)
{
if(rk>= && rk<=) return ;
if(rk>= && rk<=) return ;
if(rk>= && rk<=) return ;
if(rk>= && rk<=) return ;
} void BeWin(int& rk,int& con,int& star)
{
if(rk==)
return;
else if(rk>= && rk<=)
{
if(con>=) star+=;
else star++;
if(star > query(rk))
{
star = star-query(rk);
rk--;
}
}
else
{
star++;
if(star > query(rk))
{
star = star-query(rk);
rk--;
}
}
} void BeLost(int& rk,int& star)
{
if(rk==)
return;
else if(rk>= && rk<=)
{
if(star==)
{
if(rk<)
{
rk++;
star = query(rk)-;
}
}
else
{
star--;
}
}
} int main()
{
scanf("%s",str);
int len = strlen(str);
int rk = ,con = ,star=;
for(int i=; i<len; i++)
{
if(str[i]=='W')
{
con++;
BeWin(rk,con,star);
}
if(str[i]=='L')
{
con = ;
BeLost(rk,star);
}
}
if(rk==)
printf("Legend\n");
else
printf("%d\n",rk);
return ;
}
Game Rank(NCPC 2016 大模拟)的更多相关文章
- HDU 5920 Ugly Problem 高精度减法大模拟 ---2016CCPC长春区域现场赛
题目链接 题意:给定一个很大的数,把他们分为数个回文数的和,分的个数不超过50个,输出个数并输出每个数,special judge. 题解:现场赛的时候很快想出来了思路,把这个数从中间分为两部分,当位 ...
- AC日记——神奇的幻方 洛谷 P2615(大模拟)
题目描述 幻方是一种很神奇的N*N矩阵:它由数字1,2,3,……,N*N构成,且每行.每列及两条对角线上的数字之和都相同. 当N为奇数时,我们可以通过以下方法构建一个幻方: 首先将1写在第一行的中间. ...
- ACdream 1188 Read Phone Number (字符串大模拟)
Read Phone Number Time Limit:1000MS Memory Limit:64000KB 64bit IO Format:%lld & %llu Sub ...
- [BZOJ 4573][ZJOI 2016]大森林
[LOJ 2092][BZOJ 4573][UOJ 195][ZJOI 2016]大森林 题意 给定一个树序列, 初始时所有树都只有一个点, 要求支持三种操作: 区间种树(在某个特定点上长出一个子结点 ...
- 2016ACM-ICPC网络赛北京赛区 1001 (trie树牌大模拟)
[题目传送门] 1383 : The Book List 时间限制:1000ms 单点时限:1000ms 内存限制:256MB 描述 The history of Peking University ...
- Bzoj1972: [Sdoi2010]猪国杀 题解(大模拟+耐心+细心)
猪国杀 - 可读版本 https://mubu.com/doc/2707815814591da4 题目可真长,读题都要一个小时. 这道题很多人都说不可做,耗时间,代码量大,于是,本着不做死就不会死的精 ...
- (大模拟紫题) Luogu P1953 易语言
原题链接:P1953 易语言 (我最近怎么总在做大模拟大搜索题) 分别处理两种情况. 如果只有一个1或0 直接设一个cnt为这个值,每次输入一个新名字之后把数字替换成cnt,最后cnt++即可. 注意 ...
- NOIP2017 时间复杂度 大模拟
再写一道大模拟题. 由于是限时写的,相当于考场代码,乱的一批. 题目链接:P3952 时间复杂度 先记几个教训: 字符串形式的数字比较大小老老实实写函数,字典序都搞错几次了 栈空的时候不但pop()会 ...
- [CSP-S模拟测试]:引子(大模拟)
题目描述 网上冲浪时,$Slavko$被冲到了水箱里,水箱由上而下竖直平面.示意图如下: 数字$i$所在的矩形代表一个编号为$i$的水箱.1号水箱为水箱中枢,有水管连出.除了$1$号水箱外,其他水箱上 ...
随机推荐
- HDU 4850 Wow! Such String!
链接:http://acm.hdu.edu.cn/showproblem.php?pid=4850 题意:给定一个N(1 ≤ N ≤ 500000),构造一个长度为N的小写字母字符串,要求所有长度大于 ...
- jquery autocomplete自动补全
简单用法: $(function(){ var data = "the People's Republic of China".split(" "); $(&q ...
- easyui 生成tas方式
1.采用<a>标签形式 <div id="tabs" style="width:100%;"> <ul> <li id ...
- Could not find modernizr-2.6.2 in any of the sources GitLab: API is not accessible
Could not find modernizr-2.6.2 in any of the sources GitLab: API is not accessible bundle exec rake ...
- gitlab gerrit jenkins CI/CD环境集成
http://blog.csdn.net/williamwanglei/article/details/38498465
- 19.Extjs主页面显示js
1. /** * @author sux * @time 2011-1-11 * @desc main page */ var mainPage = Ext.extend(Ext.Viewport,{ ...
- Android 性能优化(26)*性能工具之「Batterystats,Battery Historian」Batterystats & Battery Historian Walkthrough
Batterystats & Battery Historian Walkthrough Working with Batterystats & Battery Historian B ...
- 常用点击事件(鼠标、光标、键盘、body)
常用事件: 鼠标: onclick(单击) ondblclick(双击) oncontextmenu(右击) onmouseover onmouseout 光标: onfocus onblur 键盘: ...
- Python学习日记之文件读取操作
Python内置了文件读写的函数open,read 用法示例: open('/home/root/files.txt ') 在打开文件后,操作完成后可以使用close()关闭文件,但比较好的文件读写方 ...
- DatePickerDialog和TimePickerDialog(基于对话框显示时间和日期)
public class MainActivity extends Activity implements android.view.View.OnClickListener{ private But ...